Skip to content

mp_units::QuantityOf

A concept matching all quantities of the provided property

Synopsis

Declared in <mp-units/framework/quantity_concepts.h>

template<typename Q, auto V>
concept QuantityOf =
  Quantity<Q> && ((QuantitySpec<MP_UNITS_NTTP_HACK(decltype(V))> && ReferenceOf<decltype(Q::reference), V>) ||
                  // The `QuantitySpecOf` and `RepresentationOf` part of the character branch is
                  // wrapped in a requires-expression so that it forms one atomic constraint. As plain
                  // concept-ids they normalize through every disjunction under `RepresentationOf`.
                  // Comparing two candidates by their constraints, as `a <=> b` does with its reversed
                  // candidate, then exhausts the heap of MSVC 19.51. Satisfaction is the same either way.
                  (detail::CharacterValue<V> && requires {
                    requires QuantitySpecOf<decltype(Q::quantity_spec), V> && RepresentationOf<typename Q::rep, V>;
                  }));

Description

V may be a quantity specification, in which case this is satisfied by all quantities with the reference satisfying ReferenceOf<V>, or a character (a bare quantity_tensor_order, a bare quantity_field, or a full quantity_character), in which case it is satisfied by all quantities whose specification admits that character and whose representation can fill it.

A scalar representation fills a vector or a tensor slot, a library rule generalizing clause 18 of ISO 80000-2:2019 (a scalar is a tensor of order zero, a vector one of order one). So a 1D velocity stored in a double is a vector quantity, and a quantity kind stored in a double matches every order. The specification side stays exact, so an isq::speed is never a vector quantity.

The type of V selects the reading: a specification asks only the quantity-tree question, and a character only the character question.