Constructors
Synopses
Declared in <mp‐units/framework/quantity.h>
Default constructor. Leaves the numerical value default‐initialized.
[[nodiscard]]
quantity() = default;
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);
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);
Constructs a quantity directly from a numerical value, without an explicit reference.
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);
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;
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);
Constructs a quantity from a numerical value and a reference with an equivalent unit.
Deleted overload that rejects truncating conversions of the numerical value.
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);
Parameters
Name |
Description |
q |
the source quantity to convert from |
val |
the numerical value to store |
ref |
a reference whose unit is equivalent to |
Created with MrDocs