From 77a124a3d9b9f3a0d521603b1e5e514ecb77a268 Mon Sep 17 00:00:00 2001 From: Mateusz Pusz Date: Wed, 30 Nov 2022 17:57:27 +0100 Subject: [PATCH] feat: `quantity_of` and `weak_quantity_of` now support references --- src/core/include/units/concepts.h | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/src/core/include/units/concepts.h b/src/core/include/units/concepts.h index eb9330a1..5a909819 100644 --- a/src/core/include/units/concepts.h +++ b/src/core/include/units/concepts.h @@ -101,22 +101,25 @@ inline constexpr bool is_quantity> = true; } // namespace detail /** - * @brief A concept matching all quantities with provided dimension + * @brief A concept matching all quantities with provided dimension or reference * - * Satisfied by all quantities with a dimension being the instantiation derived from - * the provided dimension type. + * Satisfied by all quantities with a dimension/reference being the instantiation derived from + * the provided dimension/reference type. */ -template -concept quantity_of = Quantity && Dimension> && (Q::dimension == D); +template +concept quantity_of = Quantity && ((Dimension> && Q::dimension == V) || + (Reference> && Q::reference == V)); /** * @brief A concept matching all quantities with provided dimension or reference * - * Satisfied by all quantities with a dimension being the instantiation derived from - * the provided dimension type. + * Satisfied by all quantities with a dimension/reference being the instantiation derived from + * the provided dimension/reference type. */ -template -concept weak_quantity_of = Quantity && Dimension> && - (interconvertible(Q::dimension, D)); +template +concept weak_quantity_of = Quantity && + ((Dimension> && interconvertible(Q::dimension, V)) || + (Reference> && + interconvertible(Q::dimension, V.dimension) && Q::unit == V.unit)); } // namespace units