constexpr auto or_else()

in src/iceberg/expected.h [1601:1613]


  constexpr auto or_else(F&& f) const&& {
    using G = std::remove_cvref_t<std::invoke_result_t<F, decltype(std::move(error()))>>;
    static_assert(expected_detail::is_specialization_v<G, expected>,
                  "G (return type of F) must be specialization of expected");
    static_assert(std::is_same_v<typename G::value_type, T>,
                  "The value type must be the same after calling the F");

    if (has_value()) {
      return G(std::in_place, std::move(this->m_val));
    } else {
      return std::invoke(std::forward<F>(f), std::move(error()));
    }
  }