Not in C ++ 03. C ++ 0x introduces decltype :
typedef decltype(C::value) type;
Some compilers have a typeof extension, though:
typedef typeof(C::value) type;
If you're ok with Boost, they have a library :
typedef BOOST_TYPEOF(C::value) type;
source share