feat: quantity::number_in(Unit auto) added + removed non-const lvalue overload of number()

Resolves #412
This commit is contained in:
Mateusz Pusz
2023-01-03 17:44:44 +01:00
parent 2cf736a1e6
commit da64f17895

View File

@@ -139,18 +139,16 @@ public:
quantity& operator=(quantity&&) = default;
// 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 rep&& number() && 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>
requires quantity_convertible_to_<quantity, quantity<::mp_units::reference<quantity_spec, U{}>{}, Rep>>