[eigen] static_cast versus constructor |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/eigen Archives
]
- To: eigen <eigen@xxxxxxxxxxxxxxxxxxx>
- Subject: [eigen] static_cast versus constructor
- From: Gael Guennebaud <gael.guennebaud@xxxxxxxxx>
- Date: Mon, 27 Aug 2012 11:44:47 +0200
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:from:date:message-id:subject:to:content-type; bh=SM/uWuwRSJubQTUhp4PjoeSftOBM7V7BYu/zVPQhiE0=; b=PHqErUiC9An98RRP4fXwpi2gngrDgisFavKYOJKBRedIk/H5pZgt8gJTBlZs70f643 yTuKodhl9iSGJ1R+sCWib/aVd0yy16PAB0fXiz5hBPigbMtmT0JdD2RzfRXp9JFOXzvQ u3E6dTZyEropYiSBMwoYbEy1L31vBMbo277FeZN3V7y2AeNmPrgKAj+G9H1uqDQldkov Sf4x0UUM9VzpuxhJD1nvkX64pSoj6LNti3o8Mq1R9f0fsc0fDumYhF7RCoyM5c9JeQzg 65CVCub5TkCkIaxq/r05/sItIAZWSa/+ytPm3wh5u7AjYSOu9nZEPa6EoQItMAbsUnlp IvFQ==
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