Integral constant can solve your problem:
struct A { template<int v, std::enable_if_t<(v <= 100)>* = nullptr> A(std::integral_constant<int, v>) {} };
Then you can use it as follows:
A a{std:integral_constant<int, 7>{}};
For ease of use, you can also use something similar to what boost::hana
does. It defines a literal operator that converts a number to an integral constant:
A a{76_c};
You can learn more about this statement in boost :: hana documentation
source share