Skip to content

Commit

Permalink
feat: quantity_ref_from disallowed for rvalues
Browse files Browse the repository at this point in the history
  • Loading branch information
mpusz committed Sep 13, 2023
1 parent 2b3c9a6 commit ff4755d
Show file tree
Hide file tree
Showing 2 changed files with 107 additions and 138 deletions.
20 changes: 3 additions & 17 deletions src/core/include/mp-units/quantity_point.h
Original file line number Diff line number Diff line change
Expand Up @@ -146,34 +146,20 @@ class quantity_point {
}

// data access
#ifdef __cpp_explicit_this_parameter
template<typename Self, std::same_as<std::remove_const_t<decltype(PO)>> PO2>
[[nodiscard]] constexpr auto&& quantity_ref_from(this Self&& self, PO2) noexcept
{
return std::forward<Self>(self).quantity_from_origin_;
}
#else
template<std::same_as<std::remove_const_t<decltype(PO)>> PO2>
[[nodiscard]] constexpr quantity_type& quantity_ref_from(PO2) & noexcept
{
return quantity_from_origin_;
}

template<std::same_as<std::remove_const_t<decltype(PO)>> PO2>
[[nodiscard]] constexpr const quantity_type& quantity_ref_from(PO2) const& noexcept
{
return quantity_from_origin_;
}

template<std::same_as<std::remove_const_t<decltype(PO)>> PO2>
[[nodiscard]] constexpr quantity_type&& quantity_ref_from(PO2) && noexcept
{
return std::move(quantity_from_origin_);
}
template<std::same_as<std::remove_const_t<decltype(PO)>> PO2>
[[nodiscard]] constexpr const quantity_type&& quantity_ref_from(PO2) const&& noexcept
{
return std::move(quantity_from_origin_);
}
#endif
constexpr const quantity_type&& quantity_ref_from(PO2) const&& noexcept = delete;

template<PointOrigin PO2>
requires requires { quantity_point{} - PO2{}; }
Expand Down
Loading

0 comments on commit ff4755d

Please sign in to comment.