templates - C++ #elif directive is being discarded -


i trying create type declaration based on boundaries

template<class b> struct intdecl {  enum {     l = b::_l, u = b::_u };  #if (l >=0 && u <=255)   typedef char type;  #elif (l>=0&&u<=65535)    typedef unsigned int type;  #endif  }; 

so, see here depending on value of l , u type defined. example

intdecl< bound < 0, 65535 > >::type i; // should unsigned int  intdecl< bound < 0, 255 > >::type i1;  // should char 

the problem , both ( i , i1) considered chars, in other words #elif being discarded. help? why #elif not executing?

the preprocessor pass happens before semantic analysis , enum semantic construct. need use templates implement this, or make l , u macros define preprocessor constants.


Comments

Popular posts from this blog

php - cannot display multiple markers in google maps v3 from traceroute result -

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -