[eigen] static_cast versus constructor

[ Thread Index | Date Index | More lists.tuxfamily.org/eigen Archives ]


Hi,

our default implementation for the .cast<NewType>() function makes use
of static_cast as in Eigen/src/Core/MathFunctions.h:395:

template<typename OldType, typename NewType>
struct cast_impl
{
  static inline NewType run(const OldType& x)
  {
    return static_cast<NewType>(x);
  }
};

Would not it be better to use constructors:

template<typename OldType, typename NewType>
struct cast_impl
{
  static inline NewType run(const OldType& x)
  {
    return NewType(x);
  }
};

which is more likely to be accepted by custom scalar types. Does
anyone see any drawbacks of such a change?

thanks,

gael



Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/