[type_traits] Obtain type of pointer to member.

Hello. I would like to know if it's possible to obtain the base type from this expression: struct MyStruct { string field1; }; decltype(&MyStruct::field1) is a pointer to member. I would like to obtain type string instead, removing the pointer to member. Is it possible? Thanks.

Germán Diago wrote:
Hello. I would like to know if it's possible to obtain the base type from this expression:
struct MyStruct { string field1; };
decltype(&MyStruct::field1) is a pointer to member. I would like to obtain type string instead, removing the pointer to member. Is it possible?
Something like the following? I know it's clumsy... but this works in
g++ 4.0.1.
#include <iostream>
#include <string>
/*------------------------------- MemberType --*/
template <typename DEFAULT>
struct MemberType
{
typedef void type;
};
template
participants (2)
-
Germán Diago
-
Nat Goodspeed