mirror of
https://github.com/mpusz/mp-units.git
synced 2025-08-02 11:54:27 +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;
|
||||
|
||||
// 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 quantity_convertible_to_<quantity, quantity<::units::reference<quantity_spec, U{}>{}, Rep>>
|
||||
|
Reference in New Issue
Block a user