mirror of
https://github.com/mpusz/mp-units.git
synced 2025-08-04 12:54:25 +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
|
||||
|
||||
/**
|
||||
* @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<typename Q, Dimension auto D>
|
||||
concept quantity_of = Quantity<Q> && Dimension<std::remove_const_t<decltype(D)>> && (Q::dimension == D);
|
||||
template<typename Q, auto V>
|
||||
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
|
||||
*
|
||||
* 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<typename Q, Dimension auto D>
|
||||
concept weak_quantity_of = Quantity<Q> && Dimension<std::remove_const_t<decltype(D)>> &&
|
||||
(interconvertible(Q::dimension, D));
|
||||
template<typename Q, auto V>
|
||||
concept weak_quantity_of = Quantity<Q> &&
|
||||
((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
|
||||
|
Reference in New Issue
Block a user