diff --git a/src/core/include/mp-units/quantity.h b/src/core/include/mp-units/quantity.h index c85bc0bec..ba362b483 100644 --- a/src/core/include/mp-units/quantity.h +++ b/src/core/include/mp-units/quantity.h @@ -151,10 +151,18 @@ class quantity { quantity& operator=(quantity&&) = default; // data access +#ifdef __cpp_explicit_this_parameter + template + [[nodiscard]] constexpr auto&& number(this Self&& self) noexcept + { + return std::forward(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 requires requires(quantity q) { q[U{}]; } diff --git a/src/core/include/mp-units/quantity_point.h b/src/core/include/mp-units/quantity_point.h index 848f7779f..9b185b93a 100644 --- a/src/core/include/mp-units/quantity_point.h +++ b/src/core/include/mp-units/quantity_point.h @@ -140,10 +140,18 @@ class quantity_point { quantity_point& operator=(quantity_point&&) = default; // data access +#ifdef __cpp_explicit_this_parameter + template + [[nodiscard]] constexpr auto&& relative(this Self&& self) noexcept + { + return std::forward(self).q_; + } +#else [[nodiscard]] constexpr quantity_type& relative() & noexcept { return q_; } [[nodiscard]] constexpr const quantity_type& relative() const& noexcept { return q_; } [[nodiscard]] constexpr quantity_type&& relative() && noexcept { return std::move(q_); } [[nodiscard]] constexpr const quantity_type&& relative() const&& noexcept { return std::move(q_); } +#endif [[nodiscard]] constexpr Quantity auto absolute() const noexcept {