mercredi 28 mars 2018

how to check if a macro is called within a class?

Say there is a macro:

#define X(...) foo(__VA_ARGS__)

foo is defined as:

void foo(int a) {}
template<class T> 
void foo(int a, T& t) { std::cout<<a<<t.b; }

I'd like to check if X is called within a class or not. If it is called within a class, then I can call the second version foo(100,*this). Otherwise, I'll call the first version without passing *this.

Aucun commentaire:

Enregistrer un commentaire