Here\'s a bit of code that might seem like it would work:
#include
#include
enum test { A = 1 };
int main()
{
int max =
From the C++11 draft:
In 18.3.2.1, about numeric_limits
:
Non-arithmetic standard types, such as complex (26.4.2), shall not have specializations.
And an enum is not an arithmetic standard type.
Then, in the non-specialized template:
template class numeric_limits {
public:
[...]
static constexpr bool is_specialized = false;
static constexpr T max() noexcept { return T(); }
};
That is, the non-specialized max()
function returns the default initialized value for that type, that is 0.