I have question regarding macros. How could I cast through macro a template class to normal class. In example:
#define RUNTIME_CLASS(class_name) ((CRuntimeClass*)(&class##class_name))
template<typename T> A {};
if (RUNTIME_CLASS(A));
I know that this code wouldn’t compile because it will not see template bit. But I don’t understand the actual macro. the return of it looks like (CRuntimeClass*)(&classA)
Why ## concatenate makes class + A ? and how preprocessor understands such notation?
Maybe where you took the macro all the class names are starting with “class” and the macro expects only the second part of the name, what comes after “class”.