C++ typename of member variable

c++, member, typename, variables

Solution

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; // gcc

If you're okay with Boost, they have a library for it:

typedef BOOST_TYPEOF(C::value) type;

Problem

Is it possible to get typename of a member variable? For example: ``` struct C { int value ; }; typedef typeof(C::value) type; // something like that? ``` Thanks

Original source