Re: [eigen] static_cast versus constructor

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


nevermind, that was a really stupid question. I've been confused by
some other issues.

sorry for the noise.

On Mon, Aug 27, 2012 at 11:44 AM, Gael Guennebaud
<gael.guennebaud@xxxxxxxxx> wrote:
> 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/