As of the ISO C++ standard of 2003, that's not an integral constant-expression. Quoting section 5.19 of the standard:
An integral constant-expression can involve only literals (2.13),
enumerators, const
variables or static data members of integral or
enumeration types initialized with constant expressions (8.5),
non-type tem-plate parameters of integral or enumeration types, and
sizeof
expressions. Floating literals (2.13.3) can appear only if
they are cast to integral or enumeration types.
You could change this:
const double rotationStep = 0.001;
const int N = 2*int(M_PI/rotationStep) + 3;
to this:
const int inverseRotationStep = 1000;
const int N = 2*int(M_PI)*inverseRotationStep + 3;
(That's assuming M_PI
is defined somewhere; it's not specified in the standard, but it's a common extension.)
The 2011 ISO C++ standard loosens this up a bit. 5.19p3 (quoting the N3337 draft) says:
An integral constant expression is a literal constant expression of
integral or unscoped enumeration type.
I think 2*int(M_PI/rotationStep) + 3
, and therefore N
, qualifies under the new rules, but it's likely your compiler doesn't yet implement them.