
Why couldn't the BOOST_TYPEOF macro be defined to simply use the new keyword, decltype, if it's available? I assume the macro, BOOST_HAS_DECLTYPE, indicates whether it is available.
And if decltype not available, why couldn't it use the conditional expression method described here:
Actually, the rvalue detection techniques in the article could be used to create a better decltype emulation on older compilers. I use this here: https://github.com/pfultz2/Zelda/blob/master/zelda/typeof.h Its a macro called ZELDA_XTYPEOF, which in C++11 is the equivalent of decltype(()) with double parenthesis. On older compilers, it will bind to a reference, unless its an rvalue which it will not have a reference. For example, say you had these functions: int by_value(); int& by_ref(); const int& by_const_ref(); Using typeof will only give int or const int, but with decltype and ZELDA_XTYPEOF it will accurately give you the return type: ZELDA_XTYPEOF(by_value()) // is int ZELDA_XTYPEOF(by_ref()) // is int & ZELDA_XTYPEOF(by_const_ref()) // is const int & Paul