Reputation: 24685
Why this doesn't work?
enum : long {MaxValue = std::numeric_limits<long int>::max()};
I'm getting error :Error 1 error C2057: expected constant expression
What isn't constant about it? Limits of long int are known at compile time so what's the problem?
Upvotes: 5
Views: 1470
Reputation: 10280
As the other have said, you need a constant expression (functions don't qualify). Eventually C++1x will support a wider range of constant expressions, including functions. See n2235 and Bjarne Stroustrup's FAQ entry.
Upvotes: 3