diff --git a/docs/users_guide/framework_basics/concepts.md b/docs/users_guide/framework_basics/concepts.md index ec304afa..5faab730 100644 --- a/docs/users_guide/framework_basics/concepts.md +++ b/docs/users_guide/framework_basics/concepts.md @@ -165,12 +165,8 @@ A `Reference` can either be: ### `ReferenceOf` { #ReferenceOf } -`ReferenceOf` concept is satisfied by references `T` that match the following value `V`: - -| `V` | Condition | -|----------------|-----------------------------------------------------------------------------------------------| -| `Dimension` | The dimension of a quantity specification satisfies [`DimensionOf`](#DimensionOf) concept. | -| `QuantitySpec` | The quantity specification satisfies [`QuantitySpecOf`](#QuantitySpecOf) concept. | +`ReferenceOf` concept is satisfied by references `T` which have a quantity specification that satisfies +[`QuantitySpecOf`](#QuantitySpecOf) concept. | ## `Representation` { #Representation } @@ -212,7 +208,7 @@ satisfied by all types being or deriving from an instantiation of a `quantity` c ### `QuantityOf` { #QuantityOf } -`QuantityOf` concept is satisfied by all the quantities for which a [`ReferenceOf`](#ReferenceOf) +`QuantityOf` concept is satisfied by all the quantities for which a [`QuantitySpecOf`](#QuantitySpecOf) is `true`. @@ -259,10 +255,10 @@ class template. `QuantityPointOf` concept is satisfied by all the quantity points `T` that match the following value `V`: -| `V` | Condition | -|---------------|----------------------------------------------------------------------------------| -| `Reference` | The quantity point reference satisfies [`ReferenceOf`](#ReferenceOf) concept. | -| `PointOrigin` | The _point_ and `V` have the same absolute point origin. | +| `V` | Condition | +|----------------|-----------------------------------------------------------------------------------------------------| +| `QuantitySpec` | The quantity point quantity specification satisfies [`QuantitySpecOf`](#QuantitySpecOf) concept. | +| `PointOrigin` | The _point_ and `V` have the same absolute point origin. | ## `QuantityLike` { #QuantityLike } diff --git a/src/core/include/mp-units/bits/quantity_concepts.h b/src/core/include/mp-units/bits/quantity_concepts.h index 83d9c209..bcebab84 100644 --- a/src/core/include/mp-units/bits/quantity_concepts.h +++ b/src/core/include/mp-units/bits/quantity_concepts.h @@ -52,13 +52,13 @@ template concept Quantity = detail::is_derived_from_specialization_of_quantity; /** - * @brief A concept matching all quantities with provided dimension or quantity spec + * @brief A concept matching all quantities with provided quantity spec * - * Satisfied by all quantities with a dimension/quantity_spec being the instantiation derived from - * the provided dimension/quantity_spec type. + * Satisfied by all quantities with a quantity_spec being the instantiation derived from + * the provided quantity_spec type. */ -template -concept QuantityOf = Quantity && ReferenceOf, V>; +template +concept QuantityOf = Quantity && QuantitySpecOf, QS>; /** * @brief A concept matching all external quantities like types diff --git a/src/core/include/mp-units/bits/quantity_point_concepts.h b/src/core/include/mp-units/bits/quantity_point_concepts.h index 6488a096..765717a3 100644 --- a/src/core/include/mp-units/bits/quantity_point_concepts.h +++ b/src/core/include/mp-units/bits/quantity_point_concepts.h @@ -145,15 +145,15 @@ concept SameAbsolutePointOriginAs = /** - * @brief A concept matching all quantity points with provided dimension or quantity spec + * @brief A concept matching all quantity points with provided quantity spec * - * Satisfied by all quantity points with a dimension/quantity_spec being the instantiation derived from - * the provided dimension/quantity_spec type, or quantity points having the origin with the same + * Satisfied by all quantity points with a quantity_spec being the instantiation derived from + * the provided quantity_spec type, or quantity points having the origin with the same * `absolute_point_origin`. */ template concept QuantityPointOf = - QuantityPoint && (ReferenceOf, V> || + QuantityPoint && (QuantitySpecOf, V> || detail::SameAbsolutePointOriginAs, V>); /** diff --git a/src/core/include/mp-units/bits/reference_concepts.h b/src/core/include/mp-units/bits/reference_concepts.h index 849d0427..57299f31 100644 --- a/src/core/include/mp-units/bits/reference_concepts.h +++ b/src/core/include/mp-units/bits/reference_concepts.h @@ -66,14 +66,12 @@ template } /** - * @brief A concept matching all references with provided dimension or quantity spec + * @brief A concept matching all references with provided quantity spec * - * Satisfied by all references with a dimension/quantity_spec being the instantiation derived from - * the provided dimension/quantity_spec type. + * Satisfied by all references with a quantity_spec being the instantiation derived from + * the provided quantity_spec type. */ -template -concept ReferenceOf = - Reference && (DimensionOf, V> || - QuantitySpecOf, V>); +template +concept ReferenceOf = Reference && QuantitySpecOf, QS>; } // namespace mp_units diff --git a/test/static/concepts_test.cpp b/test/static/concepts_test.cpp index 3bfd265d..4d443a8d 100644 --- a/test/static/concepts_test.cpp +++ b/test/static/concepts_test.cpp @@ -82,6 +82,9 @@ static_assert(!Dimension>); static_assert(!Dimension); static_assert(!Dimension); +// DimensionOf +// TODO add tests + // QuantitySpec struct speed : decltype(isq::length / isq::time) {}; // this is not recommended @@ -132,6 +135,9 @@ static_assert(!detail::QuantityKindSpec); static_assert(!detail::QuantityKindSpec); static_assert(!detail::QuantityKindSpec); +// QuantitySpecOf +// TODO add tests + // Unit struct metre_per_second : decltype(si::metre / si::second) {}; @@ -265,24 +271,16 @@ static_assert(ReferenceOf, static_assert(!ReferenceOf, isq::radius>); static_assert(ReferenceOf, isq::length>); static_assert(ReferenceOf, isq::radius>); -static_assert(ReferenceOf); static_assert(!ReferenceOf); -static_assert(ReferenceOf, isq::dim_length>); -static_assert(ReferenceOf, isq::dim_length>); static_assert(ReferenceOf); -static_assert(ReferenceOf); static_assert(ReferenceOf, dimensionless>); -static_assert(ReferenceOf, dimension_one>); static_assert(ReferenceOf, isq::rotation>); static_assert(ReferenceOf, dimensionless>); -static_assert(ReferenceOf, dimension_one>); static_assert(ReferenceOf); static_assert(!ReferenceOf); -static_assert(ReferenceOf); static_assert(ReferenceOf, isq::angular_measure>); static_assert(!ReferenceOf, dimensionless>); -static_assert(ReferenceOf, dimension_one>); static_assert(ReferenceOf); static_assert(ReferenceOf); static_assert(!ReferenceOf, isq::rotation>); @@ -323,24 +321,16 @@ static_assert(QuantityOf, isq::length>); static_assert(!QuantityOf, isq::radius>); static_assert(QuantityOf, isq::length>); static_assert(QuantityOf, isq::radius>); -static_assert(QuantityOf, isq::dim_length>); static_assert(!QuantityOf, isq::dim_length>); -static_assert(QuantityOf, isq::dim_length>); -static_assert(QuantityOf, isq::dim_length>); static_assert(QuantityOf, dimensionless>); -static_assert(QuantityOf, dimension_one>); static_assert(QuantityOf, dimensionless>); -static_assert(QuantityOf, dimension_one>); static_assert(QuantityOf, isq::rotation>); static_assert(QuantityOf, dimensionless>); -static_assert(QuantityOf, dimension_one>); static_assert(QuantityOf, isq::angular_measure>); static_assert(!QuantityOf, dimensionless>); -static_assert(QuantityOf, dimension_one>); static_assert(QuantityOf, isq::angular_measure>); static_assert(!QuantityOf, dimensionless>); -static_assert(QuantityOf, dimension_one>); static_assert(QuantityOf, isq::rotation>); static_assert(QuantityOf, isq::angular_measure>); static_assert(!QuantityOf, isq::rotation>);