diff --git a/src/include/units/bits/tools.h b/src/include/units/bits/tools.h index f8625825..516ca3ff 100644 --- a/src/include/units/bits/tools.h +++ b/src/include/units/bits/tools.h @@ -77,17 +77,15 @@ namespace units { namespace detail { template - struct is_ratio : std::false_type { - }; + inline constexpr bool is_ratio = false; template - struct is_ratio> : std::true_type { - }; + inline constexpr bool is_ratio> = true; } // namespace detail template - concept bool Ratio = detail::is_ratio::value; + concept bool Ratio = detail::is_ratio; // common_ratio diff --git a/src/include/units/bits/type_list.h b/src/include/units/bits/type_list.h index 865d06d2..2e25082c 100644 --- a/src/include/units/bits/type_list.h +++ b/src/include/units/bits/type_list.h @@ -30,17 +30,15 @@ namespace mp { namespace detail { template - struct is_type_list : std::false_type { - }; + inline constexpr bool is_type_list = false; template typename T, typename... Types> - struct is_type_list> : std::true_type { - }; + inline constexpr bool is_type_list> = true; } // namespace detail template - concept bool TypeList = detail::is_type_list::value; + concept bool TypeList = detail::is_type_list; // push_front diff --git a/src/include/units/dimension.h b/src/include/units/dimension.h index 4836b181..10dfb44e 100644 --- a/src/include/units/dimension.h +++ b/src/include/units/dimension.h @@ -35,7 +35,7 @@ namespace units { // dim_id_less template - struct dim_id_less : std::bool_constant < D1::value { + struct dim_id_less : std::bool_constant { }; // exp @@ -50,16 +50,14 @@ namespace units { // is_exp namespace detail { template - struct is_exp : std::false_type { - }; + inline constexpr bool is_exp = false; template - struct is_exp> : std::true_type { - }; + inline constexpr bool is_exp> = true; } // namespace detail template - concept bool Exponent = detail::is_exp::value; + concept bool Exponent = detail::is_exp; // exp_less @@ -88,16 +86,14 @@ namespace units { // is_dimension namespace detail { template - struct is_dimension : std::false_type { - }; + inline constexpr bool is_dimension = false; template - struct is_dimension> : std::bool_constant<(is_exp::value && ...)> { - }; + inline constexpr bool is_dimension> = true; } // namespace detail template - concept bool Dimension = detail::is_dimension::value; + concept bool Dimension = detail::is_dimension; // make_dimension diff --git a/src/include/units/quantity.h b/src/include/units/quantity.h index 296879a4..c8b3cd54 100644 --- a/src/include/units/quantity.h +++ b/src/include/units/quantity.h @@ -36,26 +36,20 @@ namespace units { namespace detail { template - struct is_quantity : std::false_type { - }; + inline constexpr bool is_quantity = false; template - struct is_quantity> : std::true_type { - }; + inline constexpr bool is_quantity> = true; } // namespace detail template - concept bool Quantity = detail::is_quantity::value; + concept bool Quantity = detail::is_quantity; // treat_as_floating_point template - struct treat_as_floating_point : std::is_floating_point { - }; - - template - inline constexpr bool treat_as_floating_point_v = treat_as_floating_point::value; + inline constexpr bool treat_as_floating_point = std::is_floating_point_v; // quantity_cast @@ -131,23 +125,22 @@ namespace units { using unit = U; using rep = Rep; - static_assert(!detail::is_quantity::value, "rep cannot be a quantity"); + static_assert(!Quantity, "rep cannot be a quantity"); quantity() = default; quantity(const quantity&) = default; - template - requires ConvertibleTo && - (treat_as_floating_point_v || !treat_as_floating_point_v) + template Rep2> + requires (treat_as_floating_point || !treat_as_floating_point) constexpr explicit quantity(const Rep2& r) : value_{static_cast(r)} { } template - requires Same&& ConvertibleTo && - (treat_as_floating_point_v || + requires Same && ConvertibleTo && + (treat_as_floating_point || (std::ratio_divide::den == 1 && - !treat_as_floating_point_v)) + !treat_as_floating_point)) constexpr quantity(const Q2& q) : value_{quantity_cast(q).count()} { } @@ -251,7 +244,7 @@ namespace units { } template - requires treat_as_floating_point_v> || std::ratio_multiply::den == 1 + requires treat_as_floating_point> || std::ratio_multiply::den == 1 quantity, unit, std::ratio_multiply>, std::common_type_t> constexpr operator*(const quantity& lhs, const quantity& rhs) @@ -291,7 +284,7 @@ namespace units { } template - requires treat_as_floating_point_v> || std::ratio_divide::den == 1 + requires treat_as_floating_point> || std::ratio_divide::den == 1 quantity, unit, std::ratio_divide>, std::common_type_t> constexpr operator/(const quantity& lhs, const quantity& rhs) diff --git a/src/include/units/unit.h b/src/include/units/unit.h index 3ac885fa..ea139a72 100644 --- a/src/include/units/unit.h +++ b/src/include/units/unit.h @@ -39,17 +39,15 @@ namespace units { namespace detail { template - struct is_unit : std::false_type { - }; + inline constexpr bool is_unit = false; template - struct is_unit> : std::true_type { - }; + inline constexpr bool is_unit> = true; } template - concept bool Unit = detail::is_unit::value; + concept bool Unit = detail::is_unit; // template // auto operator/(U1, U2) diff --git a/test/test_quantity.cpp b/test/test_quantity.cpp index d8ba1cf7..664c6af7 100644 --- a/test/test_quantity.cpp +++ b/test/test_quantity.cpp @@ -49,8 +49,7 @@ namespace { namespace units { template - struct treat_as_floating_point> : std::is_floating_point { - }; + inline constexpr bool treat_as_floating_point> = std::is_floating_point_v; template struct quantity_values> { @@ -248,9 +247,9 @@ namespace { static_assert(1000_m >= 1_km); static_assert(1000_m <= 1_km); -// is_quantity + // is_quantity - static_assert(units::detail::is_quantity>::value); + static_assert(Quantity>); // common_type