feat: all tags in the expression templates are now ordered by the type names

Resolves #499
This commit is contained in:
Mateusz Pusz
2024-07-12 17:48:38 +02:00
parent f0e94e06da
commit adbc77432e
5 changed files with 10 additions and 10 deletions

View File

@ -29,6 +29,7 @@
#include <mp-units/compat_macros.h>
#include <mp-units/ext/fixed_string.h>
#include <mp-units/ext/inplace_vector.h>
#include <mp-units/ext/type_name.h>
#include <mp-units/ext/type_traits.h>
#include <mp-units/framework/dimension_concepts.h>
#include <mp-units/framework/expression_template.h>
@ -55,7 +56,7 @@ MP_UNITS_EXPORT struct dimension_one;
namespace detail {
template<typename Lhs, typename Rhs>
struct base_dimension_less : std::bool_constant<(Lhs::symbol < Rhs::symbol)> {};
struct base_dimension_less : std::bool_constant<type_name<Lhs>() < type_name<Rhs>()> {};
template<typename T1, typename T2>
using type_list_of_base_dimension_less = expr_less<T1, T2, base_dimension_less>;

View File

@ -108,7 +108,7 @@ template<Unit T, auto M, typename U>
[[nodiscard]] consteval auto get_canonical_unit_impl(T, const scaled_unit_impl<M, U>&);
template<Unit Lhs, Unit Rhs>
struct unit_less : std::bool_constant<(Lhs::symbol < Rhs::symbol)> {};
struct unit_less : std::bool_constant<type_name<Lhs>() < type_name<Rhs>()> {};
template<typename T1, typename T2>
using type_list_of_unit_less = expr_less<T1, T2, unit_less>;

View File

@ -518,7 +518,7 @@ static_assert(is_of_type<isq::length(1 * m) - 1 * m, quantity<isq::length[m], in
static_assert(is_of_type<isq::length(1 * m) - 1 * km, quantity<isq::length[m], int>>);
static_assert(is_of_type<isq::length(1 * km) - 1 * m, quantity<isq::length[m], int>>);
static_assert(is_of_type<1 * N * (1 * m), quantity<derived_unit<struct si::newton, struct si::metre>{}, int>>);
static_assert(is_of_type<1 * N * (1 * m), quantity<derived_unit<struct si::metre, struct si::newton>{}, int>>);
static_assert(is_of_type<1 * m * 1, quantity<si::metre, int>>);
static_assert(is_of_type<1 * m * (1 * one), quantity<si::metre, int>>);
@ -566,7 +566,7 @@ static_assert(is_of_type<1 * m - 1. * m, quantity<si::metre, double>>);
static_assert(is_of_type<1. * km - 1 * m, quantity<si::metre, double>>);
static_assert(is_of_type<1. * m - 1 * km, quantity<si::metre, double>>);
static_assert(is_of_type<1. * N * (1 * m), quantity<derived_unit<struct si::newton, struct si::metre>{}, double>>);
static_assert(is_of_type<1. * N * (1 * m), quantity<derived_unit<struct si::metre, struct si::newton>{}, double>>);
static_assert(is_of_type<1 * m * 1., quantity<si::metre, double>>);
static_assert(is_of_type<1 * m * (1. * one), quantity<si::metre, double>>);
@ -619,7 +619,7 @@ static_assert(is_of_type<1 * m % (1 * km), quantity<si::metre, int>>);
static_assert(is_of_type<1 * m / s * (1 * s), quantity<si::metre, int>>);
static_assert(is_of_type<1 * m / s * (1 * h),
quantity<derived_unit<struct si::hour, struct si::metre, per<struct si::second>>{}, int>>);
static_assert(is_of_type<1 * m * (1 * min), quantity<derived_unit<struct si::metre, struct si::minute>{}, int>>);
static_assert(is_of_type<1 * m * (1 * min), quantity<derived_unit<struct si::minute, struct si::metre>{}, int>>);
static_assert(is_of_type<1 * s * (1 * Hz), quantity<derived_unit<struct si::hertz, struct si::second>{}, int>>);
static_assert(is_of_type<1 / (1 * min), quantity<derived_unit<struct one, per<struct si::minute>>{}, int>>);
static_assert(is_of_type<1 / (1 * Hz), quantity<derived_unit<struct one, per<struct si::hertz>>{}, int>>);

View File

@ -184,7 +184,7 @@ static_assert(unit_symbol(radian) == "rad");
// Physical constants
static_assert(unit_symbol(si2019::speed_of_light_in_vacuum) == "c");
static_assert(unit_symbol(gram * standard_gravity * si2019::speed_of_light_in_vacuum) == "c g g₀");
static_assert(unit_symbol(gram * standard_gravity * si2019::speed_of_light_in_vacuum) == "g c g₀");
static_assert(unit_symbol(gram / standard_gravity) == "g/g₀");
static_assert(unit_symbol(kilo<metre> / second / mega<iau::parsec>) == "km Mpc⁻¹ s⁻¹");

View File

@ -210,8 +210,7 @@ static_assert(kilojoule.symbol == "kJ");
static_assert(is_of_type<si::kilo<metre>, si::kilo_<metre_>>);
static_assert(is_of_type<si::kilo<joule>, si::kilo_<joule_>>);
static_assert(
is_of_type<kilometre * metre, derived_unit<std::remove_const_t<decltype(si::kilo<metre>)>, metre_>>); // !!!
static_assert(is_of_type<kilometre * metre, derived_unit<metre_, si::kilo_<metre_>>>); // !!!
static_assert(
is_of_type<kilometre / metre, derived_unit<std::remove_const_t<decltype(si::kilo<metre>)>, per<metre_>>>); // !!!
@ -331,9 +330,9 @@ static_assert(is_of_type<standard_gravity / gram, derived_unit<standard_gravity_
static_assert(is_of_type<gram / standard_gravity, derived_unit<gram_, per<standard_gravity_>>>);
static_assert(is_of_type<standard_gravity * gram / standard_gravity, gram_>);
static_assert(is_of_type<speed_of_light_in_vacuum * gram * standard_gravity,
derived_unit<speed_of_light_in_vacuum_, gram_, standard_gravity_>>);
derived_unit<gram_, speed_of_light_in_vacuum_, standard_gravity_>>);
static_assert(is_of_type<gram * standard_gravity * speed_of_light_in_vacuum,
derived_unit<speed_of_light_in_vacuum_, gram_, standard_gravity_>>);
derived_unit<gram_, speed_of_light_in_vacuum_, standard_gravity_>>);
static_assert(is_same_v<decltype(inverse(second) * metre), decltype(metre / second)>);
static_assert(is_same_v<decltype(metre * inverse(second)), decltype(metre / second)>);