constexpr auto and_then()

in src/iceberg/expected.h [2125:2137]


  constexpr auto and_then(F&& f) const&& {
    using U = std::remove_cvref_t<std::invoke_result_t<F>>;
    static_assert(expected_detail::is_specialization_v<U, iceberg::expected>,
                  "U (return type of F) must be specialization of expected");
    static_assert(std::is_same_v<typename U::error_type, E>,
                  "The error type must be the same after calling the F");

    if (has_value()) {
      return std::invoke(std::forward<F>(f));
    } else {
      return U(unexpect, std::move(error()));
    }
  }