Is there such macro in C++ (cross-compiler or compiler-specific):
#if isclass(NameSpace::MyClass)
Would be useful.
No. Preprocessing directives and macros are evaluated by the preprocessor, which completes its tasks before the code is parsed as C++. The preprocessor has no knowledge of classes or namespaces.
If you do not care about portability, the __if_exists statement in VC++ meets your needs.
There is no such thing at the preprocessing stage, so no macro.
However you can have a look at the is_class
type traits available in Boost or in C++0x that enable you to take decisions at compile time.
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