Here\'s a bit of code that might seem like it would work:
#include
#include
enum test { A = 1 };
int main()
{
int max =
The numeric_limits
is a regular class template, it is not connected to the compiler in any special way as to find out about user-defined enum
types. If you look at the
file, it has the default template definition that returns zeros for everything, and a whole bunch of type-specific specifications for the individual types, returning the right constants.
You can "plug in" your enum
into numeric_limits
by providing a specification of numeric_limits
by yourself. You can copy the one for int
from the
, and modify it to suit your needs.