| 10009 | namespace detail { |
| 10010 | template<typename... Args> |
| 10011 | constexpr void static_assert_merge_attributes(tuple<Args...> parsers) |
| 10012 | { |
| 10013 | using context_t = parse_context< |
| 10014 | false, |
| 10015 | false, |
| 10016 | char const *, |
| 10017 | char const *, |
| 10018 | default_error_handler>; |
| 10019 | using skipper_t = parser_interface<ws_parser<false, false>>; |
| 10020 | using use_parser_t = dummy_use_parser_t< |
| 10021 | char const *, |
| 10022 | char const *, |
| 10023 | context_t, |
| 10024 | skipper_t> const; |
| 10025 | using all_types = |
| 10026 | decltype(hl::transform(parsers, std::declval<use_parser_t>())); |
| 10027 | auto all_types_wrapped = hl::transform(all_types{}, detail::wrap{}); |
| 10028 | auto first_non_nope = hl::fold_left( |
| 10029 | all_types_wrapped, |
| 10030 | wrapper<nope>{}, |
| 10031 | [=](auto result, auto type) { |
| 10032 | if constexpr (is_nope_v<typename decltype(result)::type>) { |
| 10033 | return type; |
| 10034 | } else { |
| 10035 | return result; |
| 10036 | } |
| 10037 | }); |
| 10038 | using first_t = typename decltype(first_non_nope)::type; |
| 10039 | static_assert( |
| 10040 | !is_nope_v<first_t>, |
| 10041 | "It looks like you wrote merge[p1 >> p2 >> ... pn], and none " |
| 10042 | "of the parsers p1, p2, ... pn produces an attribute. Please " |
| 10043 | "fix."); |
| 10044 | if constexpr (is_nope_v<first_t>) { |
| 10045 | [[maybe_unused]] detail::print_type<tuple<Args...>> tuple_types; |
| 10046 | [[maybe_unused]] detail::print_type<all_types> attribute_types; |
| 10047 | } |
| 10048 | hl::for_each(all_types_wrapped, [=](auto type) { |
| 10049 | using t = typename decltype(type)::type; |
| 10050 | if constexpr (!is_nope_v<t>) { |
| 10051 | static_assert( |
| 10052 | std::is_same_v<t, first_t>, |
| 10053 | "If you see an error here, you wrote merge[p1 >> " |
| 10054 | "p2 >> ... pn] where at least one of the types in " |
| 10055 | "ATTR(p1), ATTR(p2), ... ATTR(pn) is not the same " |
| 10056 | "type as one of the others."); |
| 10057 | if constexpr (!std::is_same_v<t, first_t>) { |
| 10058 | [[maybe_unused]] detail::print_type<tuple<Args...>> |
| 10059 | tuple_types(parsers); |
| 10060 | [[maybe_unused]] detail::print_type<all_types> |
| 10061 | attribute_types; |
| 10062 | [[maybe_unused]] detail::print_type<first_t> first_type; |
| 10063 | [[maybe_unused]] detail::print_type<t> this_type; |
| 10064 | } |
| 10065 | } |
| 10066 | }); |
| 10067 | } |
| 10068 | } |
no test coverage detected