Re: [eigen] static_cast versus constructor |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/eigen Archives
]
- To: eigen <eigen@xxxxxxxxxxxxxxxxxxx>
- Subject: Re: [eigen] static_cast versus constructor
- From: Gael Guennebaud <gael.guennebaud@xxxxxxxxx>
- Date: Mon, 27 Aug 2012 11:58:24 +0200
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type; bh=if/g/kDSfFRssyJlkkkfrG22Pauy4Q2d/FnGUeVOVhg=; b=fEEKsyMWNfsNn3+5XphblKPXNMgT/krQ3e0iuIOrZsbS7D/BUWqJIm3DbdpHcOEN8s B2Y+jPHLBadGwnS/nWklcnzHl0Q9496PQZ6nPft4dWdv4A+AM24fZctKg4wQVHQ5vtmP plfRUslk4R6uVTjfZ9Ggs5xFqGZj16Uu8l99LAskUVsxphPy4N1i8EUVIYaUt0EW/mea k3sI+vxwM/3fDmcSz1lmUiyIcITTY17+9at089qW50zokuaW1p8kO0YajB+twHqSgPBD /5Kaph096vjuVcFbWGXwSWdhB4mjvLlOdEZyR2GDKz2XZ8ByA7Szas8f3yDVBokKEMic Um5A==
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