Get typedef of current class

I am currently using boost :: intrusive_ptr along with my GUIs. Although this is a more or less convenient question, is there a way to get the name of the current class? The reason I'm asking is because I have a macro for typedef'ing different types of pointers:

#define INTRUSIVE_PTR_TYPEDEFS(CLASSNAME) typedef boost::intrusive_ptr<CLASSNAME> Ptr; \ typedef boost::intrusive_ptr<const CLASSNAME> CPtr; \ typedef CLASSNAME* WeakPtr; \ typedef const CLASSNAME* CWeakPtr; ... class Widget { public: INTRUSIVE_PTR_TYPEDEFS(Widget); ... }; class Button : public Widget { public: INTRUSIVE_PTR_TYPEDEFS(Button); ... }; 

It would be much more convenient to automatically output CLASSNAME so that you can simply copy it to the body of the class. I am using the compiler that comes with Visual Studio 2010.

Thanks in advance!

+4
source share
2 answers

No, this cannot be done in C ++.

+8
source

Hmm, one idea I have is to call the constructor and typename on this pointer ... Another way would be to create a template metaprogram for creating classes that would also make typedefs.

0
source

All Articles