Boost logo

Boost :

From: Phil Bouchard (philippe_at_[hidden])
Date: 2008-06-06 22:41:49


"Simonson, Lucanus J" <lucanus.j.simonson_at_[hidden]> wrote in message
news:33E1C72C74DBE747B7B59C1740F74437035DF242_at_orsmsx417.amr.corp.intel.com...

[...]

> It looks like we are casting a constant integer to void*, which it
> doesn't like. Obviously we could force the compiler to eat the line by
> changing static_cast to reinterpret_cast, but that isn't good.
>
> Instead of casting to an integer constant, we could construct a T from
> the integer constant:
>
> std::numeric_limits<T>::quiet_NaN() : T(1));

Exactly but quiet_NaN() will return false and I think there might be
alignment convertions depending on the type of the pointer in the first
place. It may hence be rounded down to 0 if we use an "int *" on a SPARC
machine for example. If we want to have the lowest possible value of a
pointer type we'll have to have something like:
std::numeric_limits<T>::quiet_NaN() : T(0) + 1);

-Phil


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk