From be58a6e03ad44784f930e87d98731947cc784d53 Mon Sep 17 00:00:00 2001 From: Mateusz Pusz Date: Thu, 22 Dec 2022 16:48:28 +0100 Subject: [PATCH] refactor: `quantity_spec::operator[]` return type constrained with `Reference` concept --- 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 626f7c3d..bc08cdd7 100644 --- a/src/core/include/units/quantity_spec.h +++ b/src/core/include/units/quantity_spec.h @@ -233,7 +233,7 @@ struct derived_quantity_spec : detail::expr_fractions, Q #ifdef __cpp_explicit_this_parameter template - [[nodiscard]] consteval auto operator[](this const Self, U u) + [[nodiscard]] consteval Reference auto operator[](this const Self, U u) requires(dimension == detail::get_dimension_for(u)) { return reference{}; @@ -241,7 +241,7 @@ struct derived_quantity_spec : detail::expr_fractions, Q #else // TODO can we somehow return an explicit reference type here? template - [[nodiscard]] consteval auto operator[](U u) const + [[nodiscard]] consteval Reference auto operator[](U u) const requires(dimension == detail::get_dimension_for(u)) { return reference{}; @@ -318,12 +318,12 @@ struct quantity_spec { #ifdef __cpp_explicit_this_parameter template - [[nodiscard]] consteval auto operator[](this const Self, U u) + [[nodiscard]] consteval Reference 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 auto operator[](U u) const + [[nodiscard]] consteval Reference auto operator[](U u) const requires(dimension == detail::get_dimension_for(u)) #endif { @@ -386,7 +386,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 auto operator[](U u) const + [[nodiscard]] consteval Reference auto operator[](U u) const requires(this->dimension == detail::get_dimension_for(u)) { return reference{};