
On 12/17/05 12:17 AM, "Eric Niebler" <eric@boost-consulting.com> 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