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?
The problem is that although std::numeric_limits<long int>::max()
function returns constant value it is called in run-time and you need constant value in compile-time
Probably you can just use LONG_MAX
value instead (see climits header)?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With