| 3440 | typename Context, |
| 3441 | typename SkipParser> |
| 3442 | auto call( |
| 3443 | Iter & first, |
| 3444 | Sentinel last, |
| 3445 | Context const & context, |
| 3446 | SkipParser const & skip, |
| 3447 | detail::flags flags, |
| 3448 | bool & success) const |
| 3449 | { |
| 3450 | use_parser_t<Iter, Sentinel, Context, SkipParser> const use_parser{ |
| 3451 | first, last, context, skip, flags, success}; |
| 3452 | |
| 3453 | // A result type for each of the parsers in parsers_. |
| 3454 | using all_types = |
| 3455 | decltype(detail::hl::transform(parsers_, use_parser)); |
| 3456 | |
| 3457 | // Same as above, wrapped in detail::wrapper. |
| 3458 | using all_types_wrapped = |
| 3459 | decltype(detail::hl::transform(all_types{}, detail::wrap{})); |
| 3460 | |
| 3461 | // Returns a tuple<> containing two things: 1) A tuple of only the |
| 3462 | // unique wrapped types from above, without nopes; this may be |
| 3463 | // empty. 2) std::true_type or std::false_type indicating whether |
| 3464 | // nopes were found; if so, the final result is an optional. |
| 3465 | auto append_unique = [](auto result, auto x) { |
| 3466 | using x_type = typename decltype(x)::type; |
| 3467 | if constexpr (detail::is_nope_v<x_type>) { |
| 3468 | return detail::hl::make_pair( |
| 3469 | detail::hl::first(result), std::true_type{}); |
| 3470 | } else if constexpr (detail::hl::contains( |
| 3471 | detail::hl::first(result), x)) { |
| 3472 | return result; |
| 3473 | } else { |
| 3474 | return detail::hl::make_pair( |
| 3475 | detail::hl::append(detail::hl::first(result), x), |
| 3476 | detail::hl::second(result)); |
| 3477 | } |
| 3478 | }; |
| 3479 | using wrapped_unique_types = decltype(detail::hl::fold_left( |
| 3480 | all_types_wrapped{}, |
| 3481 | detail::hl::make_pair(tuple<>{}, std::false_type{}), |
| 3482 | append_unique)); |
| 3483 | |
| 3484 | // Same as above, with the tuple types unwrapped. |
| 3485 | using unwrapped_types = decltype(detail::hl::make_pair( |
| 3486 | detail::hl::transform( |
| 3487 | detail::hl::first(wrapped_unique_types{}), |
| 3488 | detail::unwrap{}), |
| 3489 | detail::hl::second(wrapped_unique_types{}))); |
| 3490 | |
| 3491 | // Types above converted to a "variant", which may actually be a |
| 3492 | // non-variant type T if that is the only unique non-nope type, or a |
| 3493 | // nope if unwrapped_types is empty. |
| 3494 | using result_t = detail::to_hana_tuple_or_type_t<unwrapped_types>; |
| 3495 | |
| 3496 | result_t retval{}; |
| 3497 | call(first, last, context, skip, flags, success, retval); |
| 3498 | return retval; |
| 3499 | } |
no test coverage detected