C++ type of enclosing class in static member function
I assume this is outright impossible, but what if. Is it possible to somehow get type of enclosing class in a static member function, in any version of C++? class Impossible { public: static void Fun() { typedef Impossible EnclosingClass; // now do something with EnclosingClass ... } } Is there a way to get the type of the enclosing class ( Impossible in this case) without writing the name of the class in the function? The reason why I'd like to do that is to avoid repeating the class name in the function. It could easily lead to a hard to find copy-paste bug, if something like this happened: