mirror of
https://github.com/mpusz/mp-units.git
synced 2025-08-04 04:44:27 +02:00
feat: quantity_of
and weak_quantity_of
now support references
This commit is contained in:
@@ -101,22 +101,25 @@ inline constexpr bool is_quantity<quantity<R, Rep>> = true;
|
|||||||
} // namespace detail
|
} // 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
|
* Satisfied by all quantities with a dimension/reference being the instantiation derived from
|
||||||
* the provided dimension type.
|
* the provided dimension/reference type.
|
||||||
*/
|
*/
|
||||||
template<typename Q, Dimension auto D>
|
template<typename Q, auto V>
|
||||||
concept quantity_of = Quantity<Q> && Dimension<std::remove_const_t<decltype(D)>> && (Q::dimension == D);
|
concept quantity_of = Quantity<Q> && ((Dimension<std::remove_const_t<decltype(V)>> && Q::dimension == V) ||
|
||||||
|
(Reference<std::remove_const_t<decltype(V)>> && Q::reference == V));
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief A concept matching all quantities with provided dimension or reference
|
* @brief A concept matching all quantities with provided dimension or reference
|
||||||
*
|
*
|
||||||
* Satisfied by all quantities with a dimension being the instantiation derived from
|
* Satisfied by all quantities with a dimension/reference being the instantiation derived from
|
||||||
* the provided dimension type.
|
* the provided dimension/reference type.
|
||||||
*/
|
*/
|
||||||
template<typename Q, Dimension auto D>
|
template<typename Q, auto V>
|
||||||
concept weak_quantity_of = Quantity<Q> && Dimension<std::remove_const_t<decltype(D)>> &&
|
concept weak_quantity_of = Quantity<Q> &&
|
||||||
(interconvertible(Q::dimension, D));
|
((Dimension<std::remove_const_t<decltype(V)>> && interconvertible(Q::dimension, V)) ||
|
||||||
|
(Reference<std::remove_const_t<decltype(V)>> &&
|
||||||
|
interconvertible(Q::dimension, V.dimension) && Q::unit == V.unit));
|
||||||
|
|
||||||
} // namespace units
|
} // namespace units
|
||||||
|
Reference in New Issue
Block a user