M
mrstephengross
Hi folks! I'm trying to do something that I'm pretty sure you can't do
in C++. But what the heck! Maybe it can work...
I want to figure out how to use macros and templates to turn the
following code snippet:
void SomeClass::someFunction() { /* ... */ }
Into:
void SomeClass::someFunction() { typeid(SomeClass); }
So far, I haven't figured much out. Consider the following macro:
#define FOO(f) f typeid(#f);
It will turn:
void FOO(SomeClass::someFunction() {) /* ... */ }
into:
void SomeClass::someFunction() { typeid(SomeClass::someFunction {); }
Which of course won't compile. The preprocessor is very limited, and
can't parse apart macro arguments. I'm wondering if there's some way to
do it with templates. For instance:
#define FOO(f) f typeid(mymagictemplate<#f>::type);
Any ideas? So far I've come up short.
Thanks,
--Steve ([email protected])
in C++. But what the heck! Maybe it can work...
I want to figure out how to use macros and templates to turn the
following code snippet:
void SomeClass::someFunction() { /* ... */ }
Into:
void SomeClass::someFunction() { typeid(SomeClass); }
So far, I haven't figured much out. Consider the following macro:
#define FOO(f) f typeid(#f);
It will turn:
void FOO(SomeClass::someFunction() {) /* ... */ }
into:
void SomeClass::someFunction() { typeid(SomeClass::someFunction {); }
Which of course won't compile. The preprocessor is very limited, and
can't parse apart macro arguments. I'm wondering if there's some way to
do it with templates. For instance:
#define FOO(f) f typeid(mymagictemplate<#f>::type);
Any ideas? So far I've come up short.
Thanks,
--Steve ([email protected])