
"Andy Little" <andy@servocomm.freeserve.co.uk> wrote in message news:d9ccs0$qm7$2@sea.gmane.org...
"Alexander Nasonov" <alnsn-boost@yandex.ru> wrote in message news:loom.20050622T171035-650@post.gmane.org...
Andy Little <andy <at> servocomm.freeserve.co.uk> writes:
Isnt any use case for this covered by Boost.Typeof ?
Quote from Boost.Typeof documentation:
Other integral types, such as *enums*, need to be described explicitly
with
the BOOST_TYPEOF_INTEGRAL macro, like (BOOST_TYPEOF_INTEGRAL(MyEnum))
I think that applies when the type of the enum is taken, but where required enums are promoted to some integer type,dependent on numeric value. In what other situation is promotion required?
#define BOOST_TYPEOF_COMPLIANT #include <boost/typeof/typeof.hpp> #include <iostream>
struct X{ enum id{x,y}; };
int main() { BOOST_AUTO( result , X::x + X::y); std::cout << typeid(result).name() <<'\n'; }
Andy Little
FWIW, something like this: template<class T> struct promoted { typedef BOOST_TYPEOF_TPL(T()+T()) type; }; Would work on any integral type without registration. Enums can't be the result of a promotion, so no need to worry about their registration. Regards, Arkadiy