5 Quantities and units library [quantities]

5.4 Reference [qty.ref]

5.4.4 Unit [qty.unit]

5.4.4.9 Associated quantity [assoc.qty]

template<Unit U> consteval bool has-associated-quantity(U); // exposition only
Returns:
  • If U​::​quantity-spec is a valid expression, returns true.
  • Otherwise, if U​::​reference-unit is a valid expression, returns has-associated-quantity(U::reference-unit)
  • Otherwise, if is-derived-from-specialization-of<U, expr-fractions>() is true, let Nums and Dens be packs denoting the template arguments of U​::​nums and U​::​dens, respectively.
    Returns (... && has-associated-quantity(expr-type<Nums>{})) && (... && has-associated-quantity(expr-type<Dens>{}))
  • Otherwise, returns false.
template<AssociatedUnit U> consteval auto get-associated-quantity(U u); // exposition only
Returns:
  • If U is of the form common_unit<Us...>, returns get_common_quantity_spec(get-associated-quantity(Us{})...)
  • Otherwise, if U​::​quantity-spec is a valid expression, returns remove-kind(U::quantity-spec)
  • Otherwise, if U​::​reference-unit is a valid expression, returns get-associated-quantity(U::reference-unit)
  • Otherwise, if is-derived-from-specialization-of<U, expr-fractions>() is true, returns expr-map<to-quantity-spec, derived_quantity_spec, struct dimensionless>(u) where to-quantity-spec is defined as follows: template<AssociatedUnit U> using to-quantity-spec = decltype(get-associated-quantity(U{})); // exposition only