I’m trying to extract the class type from a pointer passed into a macro. Here’s what i have so far
template <class CLASS> class getter
{
public:
typedef CLASS type;
};
template <class CLASS> getter<CLASS> func(const CLASS* const)
{
return getter<CLASS>();
}
...
#define GETTYPE(PTR) func(p)::type
...
MyClass *p = new MyClass;
...
GETTYPE(p) myClass;
Is this even possible? Am I barking up the wrong tree?
You can use
decltypein C++11.