Is it possible to know the range of an non-fixed enumerator?

Viewed 66

Is there a way to know the range of values of an enumeration? I was expecting some type_traits template like std::numeric_limits, but I have found no one.

For example:

enum enm { A = -5, B = 3 };

std::cout << std::range_of_enum<enm>::min() << ', '
          << std::range_of_enum<enm>::max() << std::endl;
// Prints -8, 7 with two's complement representation, and -7, 7 
// with one's complement representation.

NOTE: For those who don't know what is the "enumeration range" (a non-standard term though), go to this question.

1 Answers
Related