$include_dir="/home/hyper-archives/boost/include"; include("$include_dir/msg-header.inc") ?>
From: Daryle Walker (darylew_at_[hidden])
Date: 2005-12-18 16:12:11
On 12/17/05 12:17 AM, "Eric Niebler" <eric_at_[hidden]> wrote:
> template<typename T>
> struct probe
> {
> operator T ();
> operator T volatile const &() const;
> };
>
> template<typename T>
> probe<T> make_probe(T const &);
>
> template<typename T>
> char is_volatile(T const &);
>
> template<typename T>
> double is_volatile(T const volatile &);
>
> #define IS_RVALUE(x) \
> (\
> sizeof(char) == \
> sizeof(is_volatile(true?make_probe(x):(x)))\
> )
Other versions of the "choose via 'sizeof' comparisons" trick, including
ones I've seen in Boost, use types like "char[1]" and "char[2]". Why?
Because there is no ban on _all_ built-in types being the same size(*). So
the assumption of "sizeof(char) != sizeof(double)" can fail.
* Which would have to be at least 32 bits (or 64 in C99).
-- Daryle Walker Mac, Internet, and Video Game Junkie darylew AT hotmail DOT com