diff --git a/src/core/include/mp-units/framework/representation_concepts.h b/src/core/include/mp-units/framework/representation_concepts.h index 6d5f81e1..43100481 100644 --- a/src/core/include/mp-units/framework/representation_concepts.h +++ b/src/core/include/mp-units/framework/representation_concepts.h @@ -75,14 +75,14 @@ template concept WeaklyRegular = std::copyable && std::equality_comparable; template -concept ScalableWith = WeaklyRegular && requires(T v, S s) { +concept ScalableWith = WeaklyRegular && requires(const T v, const S s) { { v* s / s } -> std::common_with; { s* v / s } -> std::common_with; { v / s* s } -> std::common_with; }; template -concept Scalar = (!disable_scalar) && WeaklyRegular && requires(T a, T b) { +concept Scalar = (!disable_scalar) && WeaklyRegular && requires(const T a, const T b) { { -a } -> std::common_with; { a + b } -> std::common_with; { a - b } -> std::common_with; @@ -172,8 +172,7 @@ constexpr bool disable_complex = false; namespace detail { template -concept Complex = (!disable_complex) && WeaklyRegular && requires(T a, T b) { - // complex operations +concept Complex = (!disable_complex) && WeaklyRegular && requires(const T a, const T b, const T& c) { { -a } -> std::common_with; { a + b } -> std::common_with; { a - b } -> std::common_with; @@ -183,7 +182,7 @@ concept Complex = (!disable_complex) && WeaklyRegular && requires(T a, T b ::mp_units::imag(a); ::mp_units::modulus(a); requires ScalableWith; - requires std::constructible_from; + requires std::constructible_from; }; namespace magnitude_impl { @@ -234,8 +233,7 @@ constexpr bool disable_vector = false; namespace detail { template -concept Vector = (!disable_vector) && WeaklyRegular && requires(T a, T b) { - // vector operations +concept Vector = (!disable_vector) && WeaklyRegular && requires(const T a, const T b) { { -a } -> std::common_with; { a + b } -> std::common_with; { a - b } -> std::common_with; @@ -266,7 +264,7 @@ using scaling_factor_type_t = conditional, long doubl // TODO how can we use `(!Quantity)` below? template -concept ScalarRepresentation = (!is_quantity) && Scalar && requires(T v, scaling_factor_type_t f) { +concept ScalarRepresentation = (!is_quantity) && Scalar && requires(const T v, const scaling_factor_type_t f) { // scaling { v* f } -> std::common_with; { f* v } -> std::common_with; @@ -274,18 +272,19 @@ concept ScalarRepresentation = (!is_quantity) && Scalar && requires(T v, s }; template -concept ComplexRepresentation = (!is_quantity) && Complex && requires(T v, scaling_factor_type_t f) { - // scaling - // TODO The below conversion to `T` is an exception compared to other representation types - // `std::complex` * `U` do not work, but `std::complex` is convertible from `U` - // Maybe expose this as a customization point? - { v* T(f) } -> std::common_with; - { T(f) * v } -> std::common_with; - { v / T(f) } -> std::common_with; -}; +concept ComplexRepresentation = + (!is_quantity) && Complex && requires(const T v, const scaling_factor_type_t f) { + // scaling + // TODO The below conversion to `T` is an exception compared to other representation types + // `std::complex` * `U` do not work, but `std::complex` is convertible from `U` + // Maybe expose this as a customization point? + { v* T(f) } -> std::common_with; + { T(f) * v } -> std::common_with; + { v / T(f) } -> std::common_with; + }; template -concept VectorRepresentation = (!is_quantity) && Vector && requires(T v, scaling_factor_type_t f) { +concept VectorRepresentation = (!is_quantity) && Vector && requires(const T v, const scaling_factor_type_t f) { // scaling { v* f } -> std::common_with; { f* v } -> std::common_with;