From 57d655062ce88c107209789d9bc6f7a788c75604 Mon Sep 17 00:00:00 2001 From: Mateusz Pusz Date: Thu, 22 Dec 2022 21:26:51 +0100 Subject: [PATCH] refactor: `quantity_spec::operator[]` return type constraints improved --- src/core/include/units/quantity_spec.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/core/include/units/quantity_spec.h b/src/core/include/units/quantity_spec.h index ce253ebb..5efdd8a6 100644 --- a/src/core/include/units/quantity_spec.h +++ b/src/core/include/units/quantity_spec.h @@ -197,7 +197,7 @@ struct derived_quantity_spec : detail::expr_fractions, Q #ifdef __cpp_explicit_this_parameter template - [[nodiscard]] consteval Reference auto operator[](this const Self, U u) + [[nodiscard]] consteval std::same_as> auto operator[](this const Self, U u) requires(dimension == detail::get_dimension_for(u)) { return reference{}; @@ -205,7 +205,7 @@ struct derived_quantity_spec : detail::expr_fractions, Q #else // TODO can we somehow return an explicit reference type here? template - [[nodiscard]] consteval Reference auto operator[](U u) const + [[nodiscard]] consteval std::same_as> auto operator[](U u) const requires(dimension == detail::get_dimension_for(u)) { return reference{}; @@ -289,12 +289,12 @@ struct quantity_spec { #ifdef __cpp_explicit_this_parameter template - [[nodiscard]] consteval Reference auto operator[](this const Self, U u) + [[nodiscard]] consteval std::same_as> auto operator[](this const Self, U u) requires(dimension == detail::get_dimension_for(u)) #else template // TODO can we somehow return an explicit reference type here? - [[nodiscard]] consteval Reference auto operator[](U u) const + [[nodiscard]] consteval std::same_as> auto operator[](U u) const requires(dimension == detail::get_dimension_for(u)) #endif { @@ -364,7 +364,7 @@ struct quantity_spec : std::remove_const_t { #ifndef __cpp_explicit_this_parameter template // TODO can we somehow return an explicit reference type here? - [[nodiscard]] consteval Reference auto operator[](U u) const + [[nodiscard]] consteval std::same_as> auto operator[](U u) const requires(this->dimension == detail::get_dimension_for(u)) { return reference{};