mirror of
https://github.com/mpusz/mp-units.git
synced 2025-08-06 05:34:27 +02:00
feat: quantity::number_in(Unit auto)
added + removed non-const lvalue overload of number()
Resolves #412
This commit is contained in:
@@ -139,18 +139,16 @@ public:
|
|||||||
quantity& operator=(quantity&&) = default;
|
quantity& operator=(quantity&&) = default;
|
||||||
|
|
||||||
// data access
|
// data access
|
||||||
#ifdef __cpp_explicit_this_parameter
|
|
||||||
template<typename Self>
|
|
||||||
[[nodiscard]] constexpr auto&& number(this Self&& self) noexcept
|
|
||||||
{
|
|
||||||
return std::forward<Self>(self).number_;
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
[[nodiscard]] constexpr rep& number() & noexcept { return number_; }
|
|
||||||
[[nodiscard]] constexpr const rep& number() const& noexcept { return number_; }
|
[[nodiscard]] constexpr const rep& number() const& noexcept { return number_; }
|
||||||
[[nodiscard]] constexpr rep&& number() && noexcept { return std::move(number_); }
|
[[nodiscard]] constexpr rep&& number() && noexcept { return std::move(number_); }
|
||||||
[[nodiscard]] constexpr const rep&& number() const&& noexcept { return std::move(number_); }
|
[[nodiscard]] constexpr const rep&& number() const&& noexcept { return std::move(number_); }
|
||||||
#endif
|
|
||||||
|
template<Unit U>
|
||||||
|
requires requires(quantity q) { q[U{}]; }
|
||||||
|
[[nodiscard]] constexpr rep number_in(U) const noexcept
|
||||||
|
{
|
||||||
|
return (*this)[U{}].number();
|
||||||
|
}
|
||||||
|
|
||||||
template<Unit U>
|
template<Unit U>
|
||||||
requires quantity_convertible_to_<quantity, quantity<::mp_units::reference<quantity_spec, U{}>{}, Rep>>
|
requires quantity_convertible_to_<quantity, quantity<::mp_units::reference<quantity_spec, U{}>{}, Rep>>
|
||||||
|
Reference in New Issue
Block a user