Hello all,
I am trying to use the #if directive to compile extra functionality acording to some class template parameter defined integer constant. What I want to do is this:
struct A1{
static const int _AINT = 0;
};
struct A2{
static const int _AINT = 1;
};
template< class T >
struct B{
void Fun(){
#if T::_AINT == 1
cout << " TADA! "<< endl;
#endif
};
};
int main(void){
B< A1 > b1;
B< A2 > b2;
b1.Fun();
b2.Fun();
return 0;
};
This compiles, I guess because the compiler recognizes the integer constant and accepts it. But when it runs it does not behave as (I) expected.
Can someone explain me why does this happen and maybe suggest some other way of doing it (avoiding an approach like the Strategy pattern)?
Thank you in advance
Rui