[Insight-users] operator<< issues
Pablo Ybalo
pablo at veccsa.com
Wed Oct 26 12:02:35 EDT 2005
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.
More information about the Insight-users
mailing list