Is there a reason to use three template parameters when a single one would be sufficient?
0template <typename X>
1static constexpr bool is_minimum(const X x)
2{
3 using U = typename std::underlying_type<X>::type;
4 return x == std::numeric_limits<U>::min();
5}
6
7static_assert(is_minimum(Consensus::DEPLOYMENT_HEIGHTINCB), "heightincb is not minimum value for BuriedDeployment");
8static_assert(is_minimum(Consensus::DEPLOYMENT_TESTDUMMY), "testdummy is not minimum value for DeploymentPos");
This seems verbose, confusing and dangerous. For example the following asserts are wrong, but don’t fail:
0static_assert(is_minimum<Consensus::BuriedDeployment, Consensus::BuriedDeployment, signed short>(Consensus::DEPLOYMENT_HEIGHTINCB), "heightincb is not minimum value for BuriedDeployment");
1static_assert(is_minimum<Consensus::DeploymentPos, Consensus::DeploymentPos, unsigned short>(Consensus::DEPLOYMENT_TESTDUMMY), "testdummy is not minimum value for DeploymentPos");