diff --git a/src/core/include/units/quantity_spec.h b/src/core/include/units/quantity_spec.h index 7ceda6de..626f7c3d 100644 --- a/src/core/include/units/quantity_spec.h +++ b/src/core/include/units/quantity_spec.h @@ -233,14 +233,15 @@ struct derived_quantity_spec : detail::expr_fractions, Q #ifdef __cpp_explicit_this_parameter template - [[nodiscard]] constexpr auto operator[](this const Self, U u) + [[nodiscard]] consteval auto operator[](this const Self, U u) requires(dimension == detail::get_dimension_for(u)) { return reference{}; } #else + // TODO can we somehow return an explicit reference type here? template - [[nodiscard]] constexpr auto operator[](U u) const + [[nodiscard]] consteval auto operator[](U u) const requires(dimension == detail::get_dimension_for(u)) { return reference{}; @@ -317,11 +318,12 @@ struct quantity_spec { #ifdef __cpp_explicit_this_parameter template - [[nodiscard]] constexpr auto operator[](this const Self, U u) + [[nodiscard]] consteval auto operator[](this const Self, U u) requires(dimension == detail::get_dimension_for(u)) #else template - [[nodiscard]] constexpr auto operator[](U u) const + // TODO can we somehow return an explicit reference type here? + [[nodiscard]] consteval auto operator[](U u) const requires(dimension == detail::get_dimension_for(u)) #endif { @@ -383,7 +385,8 @@ struct quantity_spec : std::remove_const_t { #ifndef __cpp_explicit_this_parameter template - [[nodiscard]] constexpr auto operator[](U u) const + // TODO can we somehow return an explicit reference type here? + [[nodiscard]] consteval auto operator[](U u) const requires(this->dimension == detail::get_dimension_for(u)) { return reference{};