refactor: quantity_spec::operator[] made consteval

This commit is contained in:
Mateusz Pusz
2022-12-22 15:58:37 +01:00
parent 1ff048a70e
commit a32eb712da

View File

@@ -233,14 +233,15 @@ struct derived_quantity_spec : detail::expr_fractions<derived_quantity_spec<>, Q
#ifdef __cpp_explicit_this_parameter
template<typename Self, Unit U>
[[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<Self{}, u>{};
}
#else
// TODO can we somehow return an explicit reference type here?
template<Unit U>
[[nodiscard]] constexpr auto operator[](U u) const
[[nodiscard]] consteval auto operator[](U u) const
requires(dimension == detail::get_dimension_for(u))
{
return reference<derived_quantity_spec{}, u>{};
@@ -317,11 +318,12 @@ struct quantity_spec<Self, Dim, Args...> {
#ifdef __cpp_explicit_this_parameter
template<typename Self, Unit U>
[[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<Unit U>
[[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<Self, Q, Args...> : std::remove_const_t<decltype(Q)> {
#ifndef __cpp_explicit_this_parameter
template<Unit U>
[[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<Self{}, u>{};