Skip to content

mp_units::QuantityPointOf

A concept matching the quantity points of a given quantity or origin

Synopsis

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

template<typename QP, auto V>
concept QuantityPointOf =
  QuantityPoint<QP> &&
  ((QuantitySpec<decltype(V)> &&
    ReferenceOf<decltype(QP::reference), V>) ||
   detail::SameAbsolutePointOriginAs<decltype(QP::absolute_point_origin), V> ||
   (detail::CharacterValue<V> && requires {
     requires QuantitySpecOf<decltype(QP::quantity_spec), V> &&
                RepresentationOf<typename QP::rep, V>;
   }));

Description

V may be a quantity specification, in which case this is satisfied by every point whose reference satisfies ReferenceOf with V, a point origin, in which case it is satisfied by every point measured from the same absolute origin, or a character (a bare quantity_tensor_order, a bare quantity_field, or a full quantity_character), in which case it is satisfied by every point of that character.

A point isn't a Quantity, so QuantityPointOf is where its character is asked.

// the ideal gas law needs a temperature measured from absolute zero, never a difference
constexpr QuantityOf<isq::pressure> auto gas_pressure(
  QuantityOf<dimensionless> auto particles, QuantityPointOf<si::absolute_zero> auto temp,
  QuantityOf<isq::volume> auto volume)
{
  return particles * si::boltzmann_constant * temp.delta_from(si::absolute_zero) / volume;
}

constexpr quantity particles = 2.5e22 * one;
constexpr quantity volume = 1. * L;
constexpr quantity pressure = gas_pressure(particles, point<K>(300.), volume);   // ≈ 103.5 kPa
constexpr quantity same = gas_pressure(particles, point<deg_C>(26.85), volume);  // in Celsius
// doesn't compile: a temperature difference isn't a temperature
// auto bad = gas_pressure(particles, delta<deg_C>(26.85), volume);

See Also