#include <stdexcept>
template <int min, int max>
class Range
{
public:
Range(int i): i(i)
{
if (i < min)
throw std::runtime_error("value lower than minimum " + std::to_string(min));
if (i > max)
throw std::runtime_error("value higher than maximum " + std::to_string(max));
}
int to_int() const { return i; };
private:
int i;
};
using Month = Range<1, 12>;
int main()
{
Month month(-1);
}
terminate called after throwing an instance of 'std::runtime_error'
what(): value lower than minimum 1