visual c++ - Typedef to surrounding type in C++ -


is there way build typedef inside type declaration declared (surrounding) type without stating type's name?

example:

class x {   public:     typedef <fill in magic here> mytype;   //... }; 

background: seems silly on first look. need because build compile-time-reflection of data classes using macros. there macro inserted declaration of data class needs deal type inserted into. far found working solutions msvc , g++ both rely on think flaws in implementation. may not work on newer version. clang not "eat" either of these solutions.

my current solution msvc defines method , takes it's address it's name , calls small helper "returns" type of it's class. (clang , g++ expect full name of method including it's class name).

my current solution g++ defines static method return type std::remove_reference(decltype(*this)). (clang , msvc not allow this in static context).

i absolutely prefer standard conform solution special solution clang ok moment.

if nothing works have pass class' name macro try avoid since have plenty of code using macro.

edit: adding sample on how reflection works (which may clarify need):

class x : public y {   public:     //.. constructor , such stuff...      int a;     double b;     std::string c;      classhead(y)       field(a)       field(b)       field(c)     classfoot }; 

classhead macro should define typedef. var_args macro arguments receive base classes. said: possible give class' name it's first argument (resulting in classhead(x, y) in example). cannot imagine there no solution such "simply" task typedef'ing surrounding type...

nohting works using class name in macro working solution


Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

javascript - Get parameter of GET request -

javascript - Twitter Bootstrap - how to add some more margin between tooltip popup and element -