value_cast overloads

Synopses

Declared in <mp‐units/framework/value_cast.h>

Explicit cast of a quantity's representation

template<
    Quantity ToQ,
    typename FwdQ,
    Quantity Q = std::remove_cvref_t<FwdQ>>
requires (ToQ::quantity_spec == Q::quantity_spec) &&
          (MP_UNITS_WEAK_UNIT_OF(MP_UNITS_NONCONST_TYPE(ToQ::unit), Q::quantity_spec)) &&
          std::constructible_from<typename ToQ::rep, typename Q::rep> &&
          detail::SaneScaling<Q::unit, ToQ::unit, typename ToQ::rep>
[[nodiscard]]
constexpr
Quantity auto
value_cast(FwdQ&& q);

Explicit cast of a quantity's representation type

template<
    typename ToRep,
    typename FwdQ,
    Quantity Q = std::remove_cvref_t<FwdQ>>
requires RepresentationOf<ToRep, Q::quantity_spec> && std::constructible_from<ToRep, typename Q::rep>
[[nodiscard]]
constexpr
quantity<Q::reference, ToRep>
value_cast(FwdQ&& q);

Explicit cast of a quantity's unit

template<
    auto ToU,
    typename FwdQ,
    Quantity Q = std::remove_cvref_t<FwdQ>>
requires (MP_UNITS_WEAK_UNIT_OF(MP_UNITS_REMOVE_CONST(decltype(ToU)), Q::quantity_spec)) &&
          detail::SaneScaling<Q::unit, ToU, typename Q::rep>
[[nodiscard]]
constexpr
Quantity auto
value_cast(FwdQ&& q);

Explicit cast of a quantity point's representation

template<
    Quantity ToQ,
    typename FwdQP,
    QuantityPoint QP = std::remove_cvref_t<FwdQP>>
requires (ToQ::quantity_spec == QP::quantity_spec) &&
          (MP_UNITS_WEAK_UNIT_OF(MP_UNITS_NONCONST_TYPE(ToQ::unit), QP::quantity_spec)) &&
          std::constructible_from<typename ToQ::rep, typename QP::rep> &&
          detail::SaneScaling<QP::unit, ToQ::unit, typename ToQ::rep>
[[nodiscard]]
constexpr
QuantityPoint auto
value_cast(FwdQP&& qp);

Explicit cast of a quantity point's representation, including potentially the point origin

template<
    QuantityPoint ToQP,
    typename FwdQP,
    QuantityPoint QP = std::remove_cvref_t<FwdQP>>
requires (ToQP::quantity_spec == QP::quantity_spec) &&
          (MP_UNITS_WEAK_UNIT_OF(MP_UNITS_NONCONST_TYPE(ToQP::unit), QP::quantity_spec)) &&
          (detail::same_absolute_point_origins(ToQP::point_origin, QP::point_origin)) &&
          std::constructible_from<typename ToQP::rep, typename QP::rep> &&
          detail::SaneScaling<QP::unit, ToQP::unit, typename ToQP::rep>
[[nodiscard]]
constexpr
QuantityPoint auto
value_cast(FwdQP&& qp);

Explicit cast of a quantity point's representation type

template<
    typename ToRep,
    typename FwdQP,
    QuantityPoint QP = std::remove_cvref_t<FwdQP>>
requires RepresentationOf<ToRep, QP::quantity_spec> && std::constructible_from<ToRep, typename QP::rep>
[[nodiscard]]
constexpr
quantity_point<QP::reference, QP::point_origin, ToRep>
value_cast(FwdQP&& qp);

Explicit cast of a quantity point's unit

template<
    Unit auto ToU,
    typename FwdQP,
    QuantityPoint QP = std::remove_cvref_t<FwdQP>>
requires (MP_UNITS_WEAK_UNIT_OF(MP_UNITS_REMOVE_CONST(decltype(ToU)), QP::quantity_spec)) &&
          detail::SaneScaling<QP::unit, ToU, typename QP::rep>
[[nodiscard]]
constexpr
QuantityPoint auto
value_cast(FwdQP&& qp);
template<
    typename ToRep,
    Unit auto ToU,
    typename FwdQ,
    Quantity Q = std::remove_cvref_t<FwdQ>>
requires (MP_UNITS_WEAK_UNIT_OF(MP_UNITS_REMOVE_CONST(decltype(ToU)), Q::quantity_spec)) &&
          RepresentationOf<ToRep, Q::quantity_spec> && std::constructible_from<ToRep, typename Q::rep> &&
          detail::SaneScaling<Q::unit, ToU, ToRep>
[[nodiscard]]
constexpr
Quantity auto
value_cast(FwdQ&& q);

Explicit cast of a quantity's unit and representation type

template<
    Unit auto ToU,
    typename ToRep,
    typename FwdQ,
    Quantity Q = std::remove_cvref_t<FwdQ>>
requires (MP_UNITS_WEAK_UNIT_OF(MP_UNITS_REMOVE_CONST(decltype(ToU)), Q::quantity_spec)) &&
          RepresentationOf<ToRep, Q::quantity_spec> && std::constructible_from<ToRep, typename Q::rep> &&
          detail::SaneScaling<Q::unit, ToU, ToRep>
[[nodiscard]]
constexpr
Quantity auto
value_cast(FwdQ&& q);
template<
    typename ToRep,
    Unit auto ToU,
    typename FwdQP,
    QuantityPoint QP = std::remove_cvref_t<FwdQP>>
requires (MP_UNITS_WEAK_UNIT_OF(MP_UNITS_REMOVE_CONST(decltype(ToU)), QP::quantity_spec)) &&
          RepresentationOf<ToRep, QP::quantity_spec> && std::constructible_from<ToRep, typename QP::rep> &&
          detail::SaneScaling<QP::unit, ToU, ToRep>
[[nodiscard]]
constexpr
QuantityPoint auto
value_cast(FwdQP&& qp);

Explicit cast of a quantity point's unit and representation type

template<
    Unit auto ToU,
    typename ToRep,
    typename FwdQP,
    QuantityPoint QP = std::remove_cvref_t<FwdQP>>
requires (MP_UNITS_WEAK_UNIT_OF(MP_UNITS_REMOVE_CONST(decltype(ToU)), QP::quantity_spec)) &&
          RepresentationOf<ToRep, QP::quantity_spec> && std::constructible_from<ToRep, typename QP::rep> &&
          detail::SaneScaling<QP::unit, ToU, ToRep>
[[nodiscard]]
constexpr
QuantityPoint auto
value_cast(FwdQP&& qp);

Template Parameters

Name

Description

ToQ

a target quantity type to which to cast the representation

ToRep

a representation type to use for a target quantity

ToU

a unit to use for a target quantity

ToQP

a target quantity point type to which to cast the representation of the point

Created with MrDocs