mirror of
https://github.com/mpusz/mp-units.git
synced 2025-08-03 20:34:26 +02:00
refactor: __cpp_explicit_this_parameter
implementation of number()
added
This commit is contained in:
@@ -147,10 +147,18 @@ 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 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>
|
template<Unit U>
|
||||||
requires quantity_convertible_to_<quantity, quantity<::units::reference<quantity_spec, U{}>{}, Rep>>
|
requires quantity_convertible_to_<quantity, quantity<::units::reference<quantity_spec, U{}>{}, Rep>>
|
||||||
|
Reference in New Issue
Block a user