I want to create a C++ class with the following type:
The use of this: think "Root" objects for a GC.
Is this possible in C++? In particular, I'm using g++. Willing to switch to clang. Either templates or macro solution fine.
Thanks!
You could do it with a macro, perhaps:
#define MY_TYPE \
do { } while(0); \
RealType
void foo() {
MY_TYPE myvar;
myvar.Whatever();
}
This would only compile inside a function (because of the "do ... while" bit - though you'd get a really weird error message). It seems like one of those "evil" uses of macros that you would want to avoid, however...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With