
11 Feb
2006
11 Feb
'06
1:43 p.m.
epsilon should be a constant known at compile time? But is the compile unable to know this?
Static assertions require an integral-constant expression, and epsilon is basically a runtime constant (at best it's a floating point constant). BTW I don't believe you can portably use DBL_EPSILON etc in a static assertion: you certainly can't use the DBL_* macros in preprocessor directives as I've found to my cost already. A vendor is entitled to implement this as: #define DBL_EPSILON __dbl_eps extern const double __dbl_eps;
Other suggestions on how to achieve a compile-time warning here?
Not really, other than checking for numeric_limits<>::is_specialized. John.