Skip to content

Commit

Permalink
variant::apply: capture non-const value by reference (#233)
Browse files Browse the repository at this point in the history
  • Loading branch information
opera-aberglund authored Sep 27, 2024
1 parent 2b0dfdc commit de453ae
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions include/cista/containers/variant.h
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ struct variant {
}

template <typename F>
auto apply(F&& f) -> decltype(f(std::declval<type_at_index_t<0U, T...>>())) {
auto apply(F&& f) -> decltype(f(std::declval<type_at_index_t<0U, T...>&>())) {
if (idx_ == NO_VALUE) {
throw_exception(std::runtime_error{"variant::apply: no value"});
}
Expand All @@ -239,7 +239,7 @@ struct variant {

template <typename F, std::size_t B = 0U, typename... Vs>
static auto apply(F&& f, index_t const idx, Vs&&... vs)
-> decltype(f((vs, std::declval<type_at_index_t<0U, T...>>())...)) {
-> decltype(f((vs, std::declval<type_at_index_t<0U, T...>&>())...)) {
switch (idx) {
case B + 0U:
if constexpr (B + 0U < sizeof...(T)) {
Expand Down

0 comments on commit de453ae

Please sign in to comment.