I use a const variable in my code. And would like to tell my pre-processor to use it. Namely:
const double x = 1.2;
const bool xIsZero = x==0;
#if xIsZero
...
#endif
But that doesn't work. In C++ 17, if constexpr doest the trick. But I'm stuck with C++11 for now.
So instead I could use a workaround like:
#define X 1.2
#define xIsZero (x==0)
const double x = X;
#if xIsZero
...
#endif
But I just dislike giving x to a #define, I'd like to give it directly to a const. Is there a way to do that?
Aucun commentaire:
Enregistrer un commentaire