I\'m getting the error
error: \'INT32_MAX\' was not declared in this scope
But I have already included
#include
#include //or
#include
std::numeric_limits::max();
Note that is a C++11 header and is a C header, included for compatibility with C standard library.
Following code works, since C++11.
#include
#include
#include
struct X
{
static const std::int32_t i = std::numeric_limits::max();
};
int main()
{
switch(std::numeric_limits::max()) {
case std::numeric_limits::max():
std::cout << "this code works thanks to constexpr\n";
break;
}
return EXIT_SUCCESS;
}
http://coliru.stacked-crooked.com/a/4a33984ede3f2f7e