[Insight-users] Operator for VariableLengthVector

Emmanuel Christophe emmanuel.christophe at gmail.com
Thu Dec 13 10:02:34 EST 2007


Hi,

I noticed that the operator / for VariableLengthVector (in
itkVariableLengthVector.h)  is defined as (as well as most operator):

  template< class T > inline Self operator/( T s ) const
    {
    Self result( m_NumElements );
    for( ElementIdentifier i=0; i< m_NumElements; i++ )
      {
      result[i] = m_Data[i] / (static_cast< ValueType >( s ));
      }
    return result;
    }

Wouldn't it make more sense to apply the cast after the operation, as:
 result[i] = static_cast< ValueType >( m_Data[i] /  s );

In the situation where the VariableLengthVector is templated on int
and s on double, the result would be closer to what is expected by the
user.

Regards,
Emmanuel


More information about the Insight-users mailing list