From 5b2978b89a7ad342db13e1205b963eeefd381441 Mon Sep 17 00:00:00 2001 From: Mateusz Pusz Date: Mon, 22 May 2023 17:55:32 +0200 Subject: [PATCH] feat: `UnitOf` concept now supports `dimensionless[radian]` --- src/core/include/mp_units/bits/unit_concepts.h | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/core/include/mp_units/bits/unit_concepts.h b/src/core/include/mp_units/bits/unit_concepts.h index 3c2f1c46..4eb4914d 100644 --- a/src/core/include/mp_units/bits/unit_concepts.h +++ b/src/core/include/mp_units/bits/unit_concepts.h @@ -164,8 +164,12 @@ concept AssociatedUnit = Unit && detail::has_associated_quantity(U{}); * Satisfied by all units associated with the quantity_spec being the instantiation derived from * the provided quantity_spec type. */ -template -concept UnitOf = AssociatedUnit && QuantitySpec> && - implicitly_convertible(get_quantity_spec(U{}), V); +template +concept UnitOf = AssociatedUnit && QuantitySpec> && + implicitly_convertible(get_quantity_spec(U{}), QS) && + // the below is to make `dimensionless[radian]` invalid + (get_kind(QS) == get_kind(get_quantity_spec(U{})) || + !std::derived_from, + std::remove_const_t>); } // namespace mp_units