[Insight-developers] operator<< issues

Pablo Ybalo pablo at veccsa.com
Mon Oct 31 08:37:05 EST 2005


Revisiting the code, I found similar approaches for same task in
* itk::Array
* itk::Size
* itk::Point

And a newbie question:
Which is the appropriate mailing list for these topics: Insight-users or
Insight-developers?

Thanks!

Pablo Ybalo


(http://public.kitware.com/pipermail/insight-users/2005-October/015412.html)
Pablo Ybalo wrote:
> Hi Luis, hi all
>
> I was looking at itkFixedArray.h and I want to propose a little change
> at operator<<.
> Currently, is defined as
>
>    template <typename TValueType, unsigned int VLength>
>    std::ostream & operator<<(std::ostream &os, const
>    FixedArray<TValueType,VLength> &arr)
>    {
>      os << "[";
>      if ( VLength == 1 )
>        {
>        os << arr[0] ;
>        }
>      else
>        {
>        for (int i=0; i < static_cast<int>(VLength) - 1; ++i)
>          {
>          os << arr[i] << ", ";
>          }
>        os << arr[VLength-1];
>        }
>      os << "]";
>      return os;
>    }
>
>
> For human readability and better compiler optimizations, I think it may
> be expressed more concisely as
>
>    template <typename TValueType, unsigned int VLength>
>    std::ostream & operator<<(std::ostream &os, const
>    FixedArray<TValueType,VLength> &arr)
>    {
>      os << "[" << arr[0] ;
>      for (unsigned int i=1; i < VLength; ++i)
>        {
>        os << ", " << arr[i];
>        }
>      os << "]";
>      return os;
>    }
>
>
> Is there some compiler issue that I am avoiding?
> Regards,
>
>    Pablo Ybalo
>    Software Development Division
>    Veccsa S.A.
>
>
> _______________________________________________
> Insight-users mailing list
> Insight-users at itk.org
> http://www.itk.org/mailman/listinfo/insight-users
>
>




More information about the Insight-developers mailing list