Constructors
Declared in <mp-units/framework/quantity.h>
Default constructor. Leaves the numerical value default-initialized.
[[nodiscard]]
quantity() = default;
» more...
Converting constructor from another quantity that shares an equivalent unit.
template<
auto R2,
typename Rep2>
requires detail::QuantityConstructibleFrom<quantity, quantity<R2, Rep2>> && (equivalent(unit, get_unit(R2)))
[[nodiscard]]
constexpr
explicit(!std::convertible_to<Rep2, rep> || !mp_units::implicitly_convertible(get_quantity_spec(R2), quantity_spec) || !mp_units::implicitly_scalable<get_unit(R2), Rep2, unit, rep>)
quantity(quantity<R2, Rep2> const& q);
» more...
Converting constructor from another quantity whose unit needs scaling to this one.
template<
auto R2,
typename Rep2>
requires detail::QuantityConstructibleFrom<quantity, quantity<R2, Rep2>> && (!equivalent(unit, get_unit(R2)))
[[nodiscard]]
constexpr
explicit(!std::convertible_to<Rep2, rep> || !mp_units::implicitly_convertible(get_quantity_spec(R2), quantity_spec) || !mp_units::implicitly_scalable<get_unit(R2), Rep2, unit, rep>)
quantity(quantity<R2, Rep2> const& q);
» more...
Constructs a quantity directly from a numerical value, without an explicit reference.
[[nodiscard]]
constexpr
explicit(!mp_units::implicitly_convertible(quantity_spec, dimensionless))
quantity(rep val)
requires detail::ExplicitFromNumber<reference>;
» more...
Constructs a quantity from a value convertible to rep, without an explicit reference.
template<typename Value>
requires detail::ExplicitFromNumber<reference> && detail::RepConstructibleFrom<rep, Value> &&
(!std::convertible_to<Value, rep>)
[[nodiscard]]
constexpr
explicit
quantity(Value val);
» more...
Deleted overload that rejects truncating conversions when constructing without a reference.
template<typename Value>
requires detail::ExplicitFromNumber<reference> && (!detail::RepConstructibleFrom<rep, Value>)
constexpr
explicit(!std::convertible_to<Value, rep> || !mp_units::implicitly_convertible(quantity_spec, dimensionless))
quantity(Value val) = delete;
» more...
Constructs a quantity from an external quantity-like type via quantity_like_traits.
template<QuantityLike Q>
requires detail::QuantityConstructibleFrom<quantity, detail::quantity_like_type<Q>>
[[nodiscard]]
constexpr
explicit(quantity_like_traits<Q>::explicit_import || !std::convertible_to<detail::quantity_like_type<Q>, quantity<R, Rep>>)
quantity(Q const& q);
» more...
Constructs a quantity from a numerical value and a reference with an equivalent unit.
template<Reference R2>
requires (equivalent(unit, get_unit(R2{})))
[[nodiscard]]
constexpr
quantity(
rep val,
R2 ref);
» more...
Deleted overload that rejects truncating conversions of the numerical value.
template<
typename Value,
Reference R2>
requires (equivalent(unit, get_unit(R2{}))) && (!detail::RepConstructibleFrom<rep, Value>)
constexpr
quantity(
Value val,
R2 ref) = delete;
» more...
Constructs a quantity from a numerical value and a reference with a different unit.
template<
typename FwdValue,
Reference R2>
requires (!equivalent(unit, get_unit(R2{}))) &&
detail::QuantityConstructibleFrom<quantity, quantity<R2{}, std::remove_cvref_t<FwdValue>>>
[[nodiscard]]
constexpr
quantity(
FwdValue&& val,
R2 ref);
» more...
| Name | Description |
|---|---|
| q | the source quantity to convert from |
| val | the numerical value to store |
| ref | a reference whose unit is equivalent to unit |