From e44bb7ed551b02fb90e93b000cdb9b106df9cec5 Mon Sep 17 00:00:00 2001 From: Mateusz Pusz Date: Sun, 1 Dec 2024 14:14:19 +0100 Subject: [PATCH] style: small cleanup of representation concepts --- .../framework/representation_concepts.h | 42 ++++++++++++------- 1 file changed, 26 insertions(+), 16 deletions(-) diff --git a/src/core/include/mp-units/framework/representation_concepts.h b/src/core/include/mp-units/framework/representation_concepts.h index 431004819..ebf12a1a2 100644 --- a/src/core/include/mp-units/framework/representation_concepts.h +++ b/src/core/include/mp-units/framework/representation_concepts.h @@ -240,21 +240,27 @@ concept Vector = (!disable_vector) && WeaklyRegular && requires(const T a, ::mp_units::magnitude(a); requires ScalableWith; // TODO should we also check for the below (e.g., when `size() > 1` or `2`) - // { zero_vector() } -> Vector; - // { unit_vector(a) } -> Vector; - // { scalar_product(a, b) } -> Scalar; - // { vector_product(a, b) } -> Vector; - // { tensor_product(a, b) } -> Tensor2; + // ::mp_units::zero_vector(); + // ::mp_units::unit_vector(a); + // ::mp_units::scalar_product(a, b); + // ::mp_units::vector_product(a, b); + // ::mp_units::tensor_product(a, b); }; +} // namespace detail + +// MP_UNITS_EXPORT template +// constexpr bool disable_tensor = false; + +namespace detail { + // TODO provide when some actual operations will be required // template -// concept Tensor = is_tensor && WeaklyRegular; // && requires(T a, T b) { -// // tensor operations -// // { tensor_product(a, b) } -> Tensor4; -// // { inner_product(a, b) } -> Tensor2; -// // { scalar_product(a, b) } -> Scalar; -// //}; +// concept Tensor = (!disable_tensor) && WeaklyRegular && requires(const T a, const T b) { +// ::mp_units::tensor_product(a, b); +// ::mp_units::inner_product(a, b); +// ::mp_units::scalar_product(a, b); +// }; template constexpr bool is_quantity = false; @@ -294,17 +300,21 @@ concept VectorRepresentation = (!is_quantity) && Vector && requires(const // template // concept TensorRepresentation = (!is_quantity) && Tensor; -template -concept IsOfCharacter = - (Ch == quantity_character::scalar && Scalar) || (Ch == quantity_character::complex && Complex) || - (Ch == quantity_character::vector && Vector); // || (Ch == quantity_character::tensor && Tensor); - } // namespace detail MP_UNITS_EXPORT template concept Representation = detail::ScalarRepresentation || detail::ComplexRepresentation || detail::VectorRepresentation; // || detail::TensorRepresentation; +namespace detail { + +template +concept IsOfCharacter = + (Ch == quantity_character::scalar && Scalar) || (Ch == quantity_character::complex && Complex) || + (Ch == quantity_character::vector && Vector); // || (Ch == quantity_character::tensor && Tensor); + +} + MP_UNITS_EXPORT template concept RepresentationOf = Representation &&