Why is C++ numeric_limits<enum_type>::max() == 0?
Here's a bit of code that might seem like it would work: #include <cassert> #include <limits> enum test { A = 1 }; int main() { int max = std::numeric_limits<test>::max(); assert(max > 0); } But it fails under both GCC (4.6.2) and clang (2.9) on Linux: max() for enum types is in fact zero! And this remains true even if you use the C++11 enum type specifier to explcitly say what type you want your enum to have. Why is this? And as for the C++11 behavior, is it something explcitly called for? I could find no mention of it in N2347, the paper on Strongly Typed Enums. std::numeric_limits is