simple_enum

simple_enum::limits Documentation

The limits namespace offers templated function objects, min and max, aimed at fetching the minimum and maximum values of an enumeration, respectively, with compile-time evaluation.

Templated Function Objects

min

#include <simple_enum/simple_enum.hpp>

enum class ExampleEnum { FirstValue = 1, SecondValue, LastValue };

constexpr ExampleEnum minValue = simple_enum::limits::min<ExampleEnum>();

max

#include <simple_enum/simple_enum.hpp>

enum class ExampleEnum { FirstValue = 1, SecondValue, LastValue };

constexpr ExampleEnum maxValue = simple_enum::limits::max<ExampleEnum>();

Notes

The min and max function objects are designed for enumeration types that are considered “bounded”, having well-defined minimum and maximum values that can be determined at compile time. They enhance the usability and safety of enum types in C++, providing clear, compile-time determinable boundaries for such types.