forked from mpusz/mp-units
refactor: quantity_spec::operator[]
return type constraints improved
This commit is contained in:
@@ -197,7 +197,7 @@ struct derived_quantity_spec : detail::expr_fractions<derived_quantity_spec<>, Q
|
|||||||
|
|
||||||
#ifdef __cpp_explicit_this_parameter
|
#ifdef __cpp_explicit_this_parameter
|
||||||
template<typename Self, Unit U>
|
template<typename Self, Unit U>
|
||||||
[[nodiscard]] consteval Reference auto operator[](this const Self, U u)
|
[[nodiscard]] consteval std::same_as<reference<Self{}, u>> auto operator[](this const Self, U u)
|
||||||
requires(dimension == detail::get_dimension_for(u))
|
requires(dimension == detail::get_dimension_for(u))
|
||||||
{
|
{
|
||||||
return reference<Self{}, u>{};
|
return reference<Self{}, u>{};
|
||||||
@@ -205,7 +205,7 @@ struct derived_quantity_spec : detail::expr_fractions<derived_quantity_spec<>, Q
|
|||||||
#else
|
#else
|
||||||
// TODO can we somehow return an explicit reference type here?
|
// TODO can we somehow return an explicit reference type here?
|
||||||
template<Unit U>
|
template<Unit U>
|
||||||
[[nodiscard]] consteval Reference auto operator[](U u) const
|
[[nodiscard]] consteval std::same_as<reference<derived_quantity_spec{}, U{}>> auto operator[](U u) const
|
||||||
requires(dimension == detail::get_dimension_for(u))
|
requires(dimension == detail::get_dimension_for(u))
|
||||||
{
|
{
|
||||||
return reference<derived_quantity_spec{}, u>{};
|
return reference<derived_quantity_spec{}, u>{};
|
||||||
@@ -289,12 +289,12 @@ struct quantity_spec<Self, Dim, Args...> {
|
|||||||
|
|
||||||
#ifdef __cpp_explicit_this_parameter
|
#ifdef __cpp_explicit_this_parameter
|
||||||
template<typename Self, Unit U>
|
template<typename Self, Unit U>
|
||||||
[[nodiscard]] consteval Reference auto operator[](this const Self, U u)
|
[[nodiscard]] consteval std::same_as<reference<Self{}, U{}>> auto operator[](this const Self, U u)
|
||||||
requires(dimension == detail::get_dimension_for(u))
|
requires(dimension == detail::get_dimension_for(u))
|
||||||
#else
|
#else
|
||||||
template<Unit U>
|
template<Unit U>
|
||||||
// TODO can we somehow return an explicit reference type here?
|
// TODO can we somehow return an explicit reference type here?
|
||||||
[[nodiscard]] consteval Reference auto operator[](U u) const
|
[[nodiscard]] consteval std::same_as<reference<Self{}, U{}>> auto operator[](U u) const
|
||||||
requires(dimension == detail::get_dimension_for(u))
|
requires(dimension == detail::get_dimension_for(u))
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
@@ -364,7 +364,7 @@ struct quantity_spec<Self, Q, Args...> : std::remove_const_t<decltype(Q)> {
|
|||||||
#ifndef __cpp_explicit_this_parameter
|
#ifndef __cpp_explicit_this_parameter
|
||||||
template<Unit U>
|
template<Unit U>
|
||||||
// TODO can we somehow return an explicit reference type here?
|
// TODO can we somehow return an explicit reference type here?
|
||||||
[[nodiscard]] consteval Reference auto operator[](U u) const
|
[[nodiscard]] consteval std::same_as<reference<Self{}, U{}>> auto operator[](U u) const
|
||||||
requires(this->dimension == detail::get_dimension_for(u))
|
requires(this->dimension == detail::get_dimension_for(u))
|
||||||
{
|
{
|
||||||
return reference<Self{}, u>{};
|
return reference<Self{}, u>{};
|
||||||
|
Reference in New Issue
Block a user