mp_units::Reference¶
A concept matching every reference
Synopsis¶
Declared in <mp-units/framework/reference_concepts.h>
template<typename T>
concept Reference = Unit<T> || is_specialization_of<std::remove_const_t<T>, reference>;
Description¶
Satisfied by every Unit, which serves as a reference on its own, and by a reference pairing a quantity specification with a unit, such as isq::height[si::metre].
// running statistics of a measured signal: the variance has the square of the mean's reference
template<Reference auto R, typename Rep = double>
struct signal_statistics {
quantity<R, Rep> mean{};
quantity<pow<2>(R), Rep> variance{};
};
signal_statistics<isq::height[mm]> heights;
// doesn't compile: a quantity specification has no unit
// signal_statistics<isq::height> bad;
// values of types nobody spells, so naming what each one is helps where `auto` alone doesn't
constexpr QuantitySpec auto power_spec = isq::energy / isq::duration;
constexpr Dimension auto power_dimension = get_dimension(power_spec);
constexpr Unit auto power_unit = si::joule / si::second;
constexpr Reference auto power_reference = power_spec[power_unit];
See Also¶
- Concepts in the User's Guide