9 #define WILDCARDS_VERSION_MAJOR 1
10 #define WILDCARDS_VERSION_MINOR 5
11 #define WILDCARDS_VERSION_PATCH 0
12 #ifndef WILDCARDS_CARDS_HPP
13 #define WILDCARDS_CARDS_HPP
28 constexpr
cards(T a, T s, T e, T so, T sc, T sn, T ao, T ac, T ar)
66 constexpr
cards(
char a,
char s,
char e)
74 constexpr
cards(
char a,
char s,
char e,
char so,
char sc,
char sn,
char ao,
char ac,
char ar)
107 constexpr
cards(char16_t a, char16_t s, char16_t e)
115 constexpr
cards(char16_t a, char16_t s, char16_t e, char16_t so, char16_t sc, char16_t sn,
116 char16_t ao, char16_t ac, char16_t ar)
149 constexpr
cards(char32_t a, char32_t s, char32_t e)
157 constexpr
cards(char32_t a, char32_t s, char32_t e, char32_t so, char32_t sc, char32_t sn,
158 char32_t ao, char32_t ac, char32_t ar)
191 constexpr
cards(
wchar_t a,
wchar_t s,
wchar_t e)
199 constexpr
cards(
wchar_t a,
wchar_t s,
wchar_t e,
wchar_t so,
wchar_t sc,
wchar_t sn,
wchar_t ao,
200 wchar_t ac,
wchar_t ar)
226 template <
typename T>
229 return {std::forward<T>(a), std::forward<T>(s), std::forward<T>(e)};
231 template <
typename T>
234 return {std::forward<T>(a), std::forward<T>(s), std::forward<T>(e),
235 std::forward<T>(so), std::forward<T>(sc), std::forward<T>(sn),
236 std::forward<T>(ao), std::forward<T>(ac), std::forward<T>(ar)};
240 #ifndef WILDCARDS_MATCH_HPP
241 #define WILDCARDS_MATCH_HPP
243 #include <type_traits>
247 #ifndef QUICKCPPLIB_HAS_FEATURE_H
248 #define QUICKCPPLIB_HAS_FEATURE_H
249 #if __cplusplus >= 201103L
250 #if !defined(__cpp_alias_templates)
251 #define __cpp_alias_templates 190000
253 #if !defined(__cpp_attributes)
254 #define __cpp_attributes 190000
256 #if !defined(__cpp_constexpr)
257 #if __cplusplus >= 201402L
258 #define __cpp_constexpr 201304
260 #define __cpp_constexpr 190000
263 #if !defined(__cpp_decltype)
264 #define __cpp_decltype 190000
266 #if !defined(__cpp_delegating_constructors)
267 #define __cpp_delegating_constructors 190000
269 #if !defined(__cpp_explicit_conversion)
270 #define __cpp_explicit_conversion 190000
272 #if !defined(__cpp_inheriting_constructors)
273 #define __cpp_inheriting_constructors 190000
275 #if !defined(__cpp_initializer_lists)
276 #define __cpp_initializer_lists 190000
278 #if !defined(__cpp_lambdas)
279 #define __cpp_lambdas 190000
281 #if !defined(__cpp_nsdmi)
282 #define __cpp_nsdmi 190000
284 #if !defined(__cpp_range_based_for)
285 #define __cpp_range_based_for 190000
287 #if !defined(__cpp_raw_strings)
288 #define __cpp_raw_strings 190000
290 #if !defined(__cpp_ref_qualifiers)
291 #define __cpp_ref_qualifiers 190000
293 #if !defined(__cpp_rvalue_references)
294 #define __cpp_rvalue_references 190000
296 #if !defined(__cpp_static_assert)
297 #define __cpp_static_assert 190000
299 #if !defined(__cpp_unicode_characters)
300 #define __cpp_unicode_characters 190000
302 #if !defined(__cpp_unicode_literals)
303 #define __cpp_unicode_literals 190000
305 #if !defined(__cpp_user_defined_literals)
306 #define __cpp_user_defined_literals 190000
308 #if !defined(__cpp_variadic_templates)
309 #define __cpp_variadic_templates 190000
312 #if __cplusplus >= 201402L
313 #if !defined(__cpp_aggregate_nsdmi)
314 #define __cpp_aggregate_nsdmi 190000
316 #if !defined(__cpp_binary_literals)
317 #define __cpp_binary_literals 190000
319 #if !defined(__cpp_decltype_auto)
320 #define __cpp_decltype_auto 190000
322 #if !defined(__cpp_generic_lambdas)
323 #define __cpp_generic_lambdas 190000
325 #if !defined(__cpp_init_captures)
326 #define __cpp_init_captures 190000
328 #if !defined(__cpp_return_type_deduction)
329 #define __cpp_return_type_deduction 190000
331 #if !defined(__cpp_sized_deallocation)
332 #define __cpp_sized_deallocation 190000
334 #if !defined(__cpp_variable_templates)
335 #define __cpp_variable_templates 190000
338 #if defined(_MSC_VER) && !defined(__clang__)
339 #if !defined(__cpp_exceptions) && defined(_CPPUNWIND)
340 #define __cpp_exceptions 190000
342 #if !defined(__cpp_rtti) && defined(_CPPRTTI)
343 #define __cpp_rtti 190000
345 #if !defined(__cpp_alias_templates) && _MSC_VER >= 1800
346 #define __cpp_alias_templates 190000
348 #if !defined(__cpp_attributes)
349 #define __cpp_attributes 190000
351 #if !defined(__cpp_constexpr) && _MSC_FULL_VER >= 190023506
352 #define __cpp_constexpr 190000
354 #if !defined(__cpp_decltype) && _MSC_VER >= 1600
355 #define __cpp_decltype 190000
357 #if !defined(__cpp_delegating_constructors) && _MSC_VER >= 1800
358 #define __cpp_delegating_constructors 190000
360 #if !defined(__cpp_explicit_conversion) && _MSC_VER >= 1800
361 #define __cpp_explicit_conversion 190000
363 #if !defined(__cpp_inheriting_constructors) && _MSC_VER >= 1900
364 #define __cpp_inheriting_constructors 190000
366 #if !defined(__cpp_initializer_lists) && _MSC_VER >= 1900
367 #define __cpp_initializer_lists 190000
369 #if !defined(__cpp_lambdas) && _MSC_VER >= 1600
370 #define __cpp_lambdas 190000
372 #if !defined(__cpp_nsdmi) && _MSC_VER >= 1900
373 #define __cpp_nsdmi 190000
375 #if !defined(__cpp_range_based_for) && _MSC_VER >= 1700
376 #define __cpp_range_based_for 190000
378 #if !defined(__cpp_raw_strings) && _MSC_VER >= 1800
379 #define __cpp_raw_strings 190000
381 #if !defined(__cpp_ref_qualifiers) && _MSC_VER >= 1900
382 #define __cpp_ref_qualifiers 190000
384 #if !defined(__cpp_rvalue_references) && _MSC_VER >= 1600
385 #define __cpp_rvalue_references 190000
387 #if !defined(__cpp_static_assert) && _MSC_VER >= 1600
388 #define __cpp_static_assert 190000
390 #if !defined(__cpp_user_defined_literals) && _MSC_VER >= 1900
391 #define __cpp_user_defined_literals 190000
393 #if !defined(__cpp_variadic_templates) && _MSC_VER >= 1800
394 #define __cpp_variadic_templates 190000
396 #if !defined(__cpp_binary_literals) && _MSC_VER >= 1900
397 #define __cpp_binary_literals 190000
399 #if !defined(__cpp_decltype_auto) && _MSC_VER >= 1900
400 #define __cpp_decltype_auto 190000
402 #if !defined(__cpp_generic_lambdas) && _MSC_VER >= 1900
403 #define __cpp_generic_lambdas 190000
405 #if !defined(__cpp_init_captures) && _MSC_VER >= 1900
406 #define __cpp_init_captures 190000
408 #if !defined(__cpp_return_type_deduction) && _MSC_VER >= 1900
409 #define __cpp_return_type_deduction 190000
411 #if !defined(__cpp_sized_deallocation) && _MSC_VER >= 1900
412 #define __cpp_sized_deallocation 190000
414 #if !defined(__cpp_variable_templates) && _MSC_FULL_VER >= 190023506
415 #define __cpp_variable_templates 190000
418 #if(defined(__GNUC__) && !defined(__clang__))
419 #define QUICKCPPLIB_GCC (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__)
420 #if !defined(__cpp_exceptions) && defined(__EXCEPTIONS)
421 #define __cpp_exceptions 190000
423 #if !defined(__cpp_rtti) && defined(__GXX_RTTI)
424 #define __cpp_rtti 190000
426 #if defined(__GXX_EXPERIMENTAL_CXX0X__)
427 #if !defined(__cpp_alias_templates) && (QUICKCPPLIB_GCC >= 40700)
428 #define __cpp_alias_templates 190000
430 #if !defined(__cpp_attributes) && (QUICKCPPLIB_GCC >= 40800)
431 #define __cpp_attributes 190000
433 #if !defined(__cpp_constexpr) && (QUICKCPPLIB_GCC >= 40600)
434 #define __cpp_constexpr 190000
436 #if !defined(__cpp_decltype) && (QUICKCPPLIB_GCC >= 40300)
437 #define __cpp_decltype 190000
439 #if !defined(__cpp_delegating_constructors) && (QUICKCPPLIB_GCC >= 40700)
440 #define __cpp_delegating_constructors 190000
442 #if !defined(__cpp_explicit_conversion) && (QUICKCPPLIB_GCC >= 40500)
443 #define __cpp_explicit_conversion 190000
445 #if !defined(__cpp_inheriting_constructors) && (QUICKCPPLIB_GCC >= 40800)
446 #define __cpp_inheriting_constructors 190000
448 #if !defined(__cpp_initializer_lists) && (QUICKCPPLIB_GCC >= 40800)
449 #define __cpp_initializer_lists 190000
451 #if !defined(__cpp_lambdas) && (QUICKCPPLIB_GCC >= 40500)
452 #define __cpp_lambdas 190000
454 #if !defined(__cpp_nsdmi) && (QUICKCPPLIB_GCC >= 40700)
455 #define __cpp_nsdmi 190000
457 #if !defined(__cpp_range_based_for) && (QUICKCPPLIB_GCC >= 40600)
458 #define __cpp_range_based_for 190000
460 #if !defined(__cpp_raw_strings) && (QUICKCPPLIB_GCC >= 40500)
461 #define __cpp_raw_strings 190000
463 #if !defined(__cpp_ref_qualifiers) && (QUICKCPPLIB_GCC >= 40801)
464 #define __cpp_ref_qualifiers 190000
466 #if !defined(__cpp_rvalue_references) && defined(__cpp_rvalue_reference)
467 #define __cpp_rvalue_references __cpp_rvalue_reference
469 #if !defined(__cpp_static_assert) && (QUICKCPPLIB_GCC >= 40300)
470 #define __cpp_static_assert 190000
472 #if !defined(__cpp_unicode_characters) && (QUICKCPPLIB_GCC >= 40500)
473 #define __cpp_unicode_characters 190000
475 #if !defined(__cpp_unicode_literals) && (QUICKCPPLIB_GCC >= 40500)
476 #define __cpp_unicode_literals 190000
478 #if !defined(__cpp_user_defined_literals) && (QUICKCPPLIB_GCC >= 40700)
479 #define __cpp_user_defined_literals 190000
481 #if !defined(__cpp_variadic_templates) && (QUICKCPPLIB_GCC >= 40400)
482 #define __cpp_variadic_templates 190000
486 #if defined(__clang__)
487 #define QUICKCPPLIB_CLANG (__clang_major__ * 10000 + __clang_minor__ * 100 + __clang_patchlevel__)
488 #if !defined(__cpp_exceptions) && (defined(__EXCEPTIONS) || defined(_CPPUNWIND))
489 #define __cpp_exceptions 190000
491 #if !defined(__cpp_rtti) && (defined(__GXX_RTTI) || defined(_CPPRTTI))
492 #define __cpp_rtti 190000
494 #if defined(__GXX_EXPERIMENTAL_CXX0X__)
495 #if !defined(__cpp_alias_templates) && (QUICKCPPLIB_CLANG >= 30000)
496 #define __cpp_alias_templates 190000
498 #if !defined(__cpp_attributes) && (QUICKCPPLIB_CLANG >= 30300)
499 #define __cpp_attributes 190000
501 #if !defined(__cpp_constexpr) && (QUICKCPPLIB_CLANG >= 30100)
502 #define __cpp_constexpr 190000
504 #if !defined(__cpp_decltype) && (QUICKCPPLIB_CLANG >= 20900)
505 #define __cpp_decltype 190000
507 #if !defined(__cpp_delegating_constructors) && (QUICKCPPLIB_CLANG >= 30000)
508 #define __cpp_delegating_constructors 190000
510 #if !defined(__cpp_explicit_conversion) && (QUICKCPPLIB_CLANG >= 30000)
511 #define __cpp_explicit_conversion 190000
513 #if !defined(__cpp_inheriting_constructors) && (QUICKCPPLIB_CLANG >= 30300)
514 #define __cpp_inheriting_constructors 190000
516 #if !defined(__cpp_initializer_lists) && (QUICKCPPLIB_CLANG >= 30100)
517 #define __cpp_initializer_lists 190000
519 #if !defined(__cpp_lambdas) && (QUICKCPPLIB_CLANG >= 30100)
520 #define __cpp_lambdas 190000
522 #if !defined(__cpp_nsdmi) && (QUICKCPPLIB_CLANG >= 30000)
523 #define __cpp_nsdmi 190000
525 #if !defined(__cpp_range_based_for) && (QUICKCPPLIB_CLANG >= 30000)
526 #define __cpp_range_based_for 190000
528 #if !defined(__cpp_raw_strings) && defined(__cpp_raw_string_literals)
529 #define __cpp_raw_strings __cpp_raw_string_literals
531 #if !defined(__cpp_raw_strings) && (QUICKCPPLIB_CLANG >= 30000)
532 #define __cpp_raw_strings 190000
534 #if !defined(__cpp_ref_qualifiers) && (QUICKCPPLIB_CLANG >= 20900)
535 #define __cpp_ref_qualifiers 190000
537 #if !defined(__cpp_rvalue_references) && defined(__cpp_rvalue_reference)
538 #define __cpp_rvalue_references __cpp_rvalue_reference
540 #if !defined(__cpp_rvalue_references) && (QUICKCPPLIB_CLANG >= 20900)
541 #define __cpp_rvalue_references 190000
543 #if !defined(__cpp_static_assert) && (QUICKCPPLIB_CLANG >= 20900)
544 #define __cpp_static_assert 190000
546 #if !defined(__cpp_unicode_characters) && (QUICKCPPLIB_CLANG >= 30000)
547 #define __cpp_unicode_characters 190000
549 #if !defined(__cpp_unicode_literals) && (QUICKCPPLIB_CLANG >= 30000)
550 #define __cpp_unicode_literals 190000
552 #if !defined(__cpp_user_defined_literals) && defined(__cpp_user_literals)
553 #define __cpp_user_defined_literals __cpp_user_literals
555 #if !defined(__cpp_user_defined_literals) && (QUICKCPPLIB_CLANG >= 30100)
556 #define __cpp_user_defined_literals 190000
558 #if !defined(__cpp_variadic_templates) && (QUICKCPPLIB_CLANG >= 20900)
559 #define __cpp_variadic_templates 190000
564 #define cfg_HAS_CONSTEXPR14 (__cpp_constexpr >= 201304)
565 #if cfg_HAS_CONSTEXPR14
566 #define cfg_constexpr14 constexpr
568 #define cfg_constexpr14
570 #if cfg_HAS_CONSTEXPR14 && defined(__clang__)
571 #define cfg_HAS_FULL_FEATURED_CONSTEXPR14 1
573 #define cfg_HAS_FULL_FEATURED_CONSTEXPR14 0
576 #ifndef CX_FUNCTIONAL_HPP
577 #define CX_FUNCTIONAL_HPP
581 template <
typename T>
584 constexpr
auto operator()(
const T& lhs,
const T& rhs)
const -> decltype(lhs < rhs)
592 template <
typename T,
typename U>
594 -> decltype(std::forward<T>(lhs) < std::forward<U>(rhs))
596 return std::forward<T>(lhs) < std::forward<U>(rhs);
599 template <
typename T>
602 constexpr
auto operator()(
const T& lhs,
const T& rhs)
const -> decltype(lhs == rhs)
610 template <
typename T,
typename U>
612 -> decltype(std::forward<T>(lhs) == std::forward<U>(rhs))
614 return std::forward<T>(lhs) == std::forward<U>(rhs);
619 #ifndef CX_ITERATOR_HPP
620 #define CX_ITERATOR_HPP
622 #include <initializer_list>
625 template <
typename It>
630 template <
typename It>
635 template <
typename C>
636 constexpr
auto size(
const C& c) -> decltype(c.size())
640 template <
typename T, std::
size_t N>
641 constexpr std::size_t
size(
const T (&)[N])
645 template <
typename C>
646 constexpr
auto empty(
const C& c) -> decltype(c.empty())
650 template <
typename T, std::
size_t N>
651 constexpr
bool empty(
const T (&)[N])
655 template <
typename E>
656 constexpr
bool empty(std::initializer_list<E> il)
658 return il.size() == 0;
660 template <
typename C>
661 constexpr
auto begin(
const C& c) -> decltype(c.begin())
665 template <
typename C>
666 constexpr
auto begin(C& c) -> decltype(c.begin())
670 template <
typename T, std::
size_t N>
675 template <
typename E>
676 constexpr
const E*
begin(std::initializer_list<E> il)
680 template <
typename C>
685 template <
typename C>
686 constexpr
auto end(
const C& c) -> decltype(c.end())
690 template <
typename C>
691 constexpr
auto end(C& c) -> decltype(c.end())
695 template <
typename T, std::
size_t N>
696 constexpr T*
end(T (&array)[N])
700 template <
typename E>
701 constexpr
const E*
end(std::initializer_list<E> il)
705 template <
typename C>
712 #ifndef WILDCARDS_UTILITY_HPP
713 #define WILDCARDS_UTILITY_HPP
714 #include <type_traits>
718 template <
typename C>
721 using type =
typename std::remove_cv<
722 typename std::remove_reference<decltype(cx::cbegin(std::declval<C>()))>
::type>
::type;
724 template <
typename C>
726 template <
typename C>
729 using type =
typename std::remove_cv<
730 typename std::remove_reference<decltype(cx::begin(std::declval<C>()))>
::type>
::type;
732 template <
typename C>
734 template <
typename It>
737 using type =
typename std::remove_cv<
738 typename std::remove_reference<decltype(*std::declval<It>())>::
type>::
type;
740 template <
typename It>
742 template <
typename C>
745 using type =
typename std::remove_cv<
746 typename std::remove_reference<decltype(*cx::begin(std::declval<C>()))>
::type>
::type;
748 template <
typename C>
754 template <
typename SequenceIterator,
typename PatternIterator>
760 constexpr
operator bool()
const
767 template <
typename SequenceIterator,
typename PatternIterator>
773 constexpr
operator bool()
const
778 template <
typename SequenceIterator,
typename PatternIterator>
783 return {std::move(res), std::move(s), std::move(
p)};
785 template <
typename SequenceIterator,
typename PatternIterator>
787 SequenceIterator s, SequenceIterator send, PatternIterator
p, PatternIterator pend,
790 return {std::move(mr.
res), std::move(s), std::move(send), std::move(mr.
s),
791 std::move(
p), std::move(pend), std::move(mr.
p)};
793 #if !cfg_HAS_FULL_FEATURED_CONSTEXPR14
796 return what_arg ==
nullptr ? false :
throw std::invalid_argument(what_arg);
798 template <
typename T>
801 return what_arg ==
nullptr ? t :
throw std::invalid_argument(what_arg);
805 return what_arg ==
nullptr ? false :
throw std::logic_error(what_arg);
807 template <
typename T>
810 return what_arg ==
nullptr ? t :
throw std::logic_error(what_arg);
820 template <
typename PatternIterator>
822 PatternIterator
p, PatternIterator pend,
826 #if cfg_HAS_CONSTEXPR14
836 if (*
p != c.set_open)
856 if (*
p == c.set_close)
862 #if cfg_HAS_FULL_FEATURED_CONSTEXPR14
863 throw std::logic_error(
864 "The program execution should never end up here throwing this exception");
867 "The program execution should never end up here throwing this exception");
874 return c.set_enabled &&
p != pend &&
884 ? *
p == c.set_close ||
886 :
throw std::logic_error(
"The program execution should never end up "
887 "here throwing this exception"));
897 template <
typename PatternIterator>
899 PatternIterator
p, PatternIterator pend,
903 #if cfg_HAS_CONSTEXPR14
906 #if cfg_HAS_FULL_FEATURED_CONSTEXPR14
907 throw std::invalid_argument(
"The use of sets is disabled");
917 if (*
p != c.set_open)
919 #if cfg_HAS_FULL_FEATURED_CONSTEXPR14
920 throw std::invalid_argument(
"The given pattern is not a valid set");
941 if (*
p == c.set_close)
947 #if cfg_HAS_FULL_FEATURED_CONSTEXPR14
948 throw std::logic_error(
949 "The program execution should never end up here throwing this exception");
952 p,
"The program execution should never end up here throwing this exception");
957 #if cfg_HAS_FULL_FEATURED_CONSTEXPR14
958 throw std::invalid_argument(
"The given pattern is not a valid set");
963 return !c.set_enabled
964 ?
throw std::invalid_argument(
"The use of sets is disabled")
966 ?
throw std::invalid_argument(
"The given pattern is not a valid set")
971 :
throw std::invalid_argument(
"The given pattern is not a valid set")
982 :
throw std::logic_error(
983 "The program execution should never end up "
984 "here throwing this exception");
995 template <
typename SequenceIterator,
typename PatternIterator,
998 SequenceIterator s, SequenceIterator send, PatternIterator
p, PatternIterator pend,
1002 #if cfg_HAS_CONSTEXPR14
1005 #if cfg_HAS_FULL_FEATURED_CONSTEXPR14
1006 throw std::invalid_argument(
"The use of sets is disabled");
1016 if (*
p != c.set_open)
1018 #if cfg_HAS_FULL_FEATURED_CONSTEXPR14
1019 throw std::invalid_argument(
"The given pattern is not a valid set");
1022 "The given pattern is not a valid set");
1028 if (*
p == c.set_not)
1038 if (equal_to(*s, *
p))
1046 if (s == send || equal_to(*s, *
p))
1053 if (*
p == c.set_close || s == send)
1057 if (equal_to(*s, *
p))
1063 if (*
p == c.set_close)
1067 if (s == send || equal_to(*s, *
p))
1073 #if cfg_HAS_FULL_FEATURED_CONSTEXPR14
1074 throw std::logic_error(
1075 "The program execution should never end up here throwing this exception");
1079 "The program execution should never end up here throwing this exception");
1084 #if cfg_HAS_FULL_FEATURED_CONSTEXPR14
1085 throw std::invalid_argument(
"The given pattern is not a valid set");
1088 "The given pattern is not a valid set");
1091 return !c.set_enabled
1092 ?
throw std::invalid_argument(
"The use of sets is disabled")
1094 ?
throw std::invalid_argument(
"The given pattern is not a valid set")
1100 throw std::invalid_argument(
"The given pattern is not a valid set")
1114 ? s == send || equal_to(*s, *
p)
1120 ? *
p == c.set_close || s == send
1124 pend, c, equal_to, state)
1129 : s == send || equal_to(*s, *
p)
1133 :
throw std::logic_error(
1134 "The program execution should never end up "
1136 "throwing this exception");
1145 template <
typename PatternIterator>
1147 PatternIterator
p, PatternIterator pend,
1151 #if cfg_HAS_CONSTEXPR14
1161 if (*
p != c.alt_open)
1173 else if (c.set_enabled && *
p == c.set_open &&
1178 else if (*
p == c.alt_open)
1182 else if (*
p == c.alt_close)
1196 throw std::logic_error(
1197 "The program execution should never end up here throwing this exception");
1204 return c.alt_enabled &&
p != pend &&
1210 : c.set_enabled && *
p == c.set_open &&
1213 pend, c, state, depth)
1223 :
throw std::logic_error(
1224 "The program execution should never end up here throwing this "
1234 template <
typename PatternIterator>
1236 PatternIterator
p, PatternIterator pend,
1240 #if cfg_HAS_CONSTEXPR14
1243 #if cfg_HAS_FULL_FEATURED_CONSTEXPR14
1244 throw std::invalid_argument(
"The use of alternatives is disabled");
1254 if (*
p != c.alt_open)
1256 #if cfg_HAS_FULL_FEATURED_CONSTEXPR14
1257 throw std::invalid_argument(
"The given pattern is not a valid alternative");
1270 else if (c.set_enabled && *
p == c.set_open &&
1275 else if (*
p == c.alt_open)
1279 else if (*
p == c.alt_close)
1292 #if cfg_HAS_FULL_FEATURED_CONSTEXPR14
1293 throw std::logic_error(
1294 "The program execution should never end up here throwing this exception");
1297 p,
"The program execution should never end up here throwing this exception");
1302 #if cfg_HAS_FULL_FEATURED_CONSTEXPR14
1303 throw std::invalid_argument(
"The given pattern is not a valid alternative");
1308 return !c.alt_enabled
1309 ?
throw std::invalid_argument(
"The use of alternatives is disabled")
1311 ?
throw std::invalid_argument(
"The given pattern is not a valid alternative")
1315 :
throw std::invalid_argument(
1316 "The given pattern is not a valid alternative")
1320 : c.set_enabled && *
p == c.set_open &&
1325 pend, c, state, depth)
1336 :
throw std::logic_error(
1337 "The program execution should never end up here throwing "
1347 template <
typename PatternIterator>
1349 PatternIterator
p, PatternIterator pend,
1353 #if cfg_HAS_CONSTEXPR14
1356 #if cfg_HAS_FULL_FEATURED_CONSTEXPR14
1357 throw std::invalid_argument(
"The use of alternatives is disabled");
1371 else if (c.set_enabled && *
p == c.set_open &&
1376 else if (*
p == c.alt_open)
1380 else if (*
p == c.alt_close)
1388 else if (*
p == c.alt_or)
1400 #if cfg_HAS_FULL_FEATURED_CONSTEXPR14
1401 throw std::logic_error(
1402 "The program execution should never end up here throwing this exception");
1405 p,
"The program execution should never end up here throwing this exception");
1410 #if cfg_HAS_FULL_FEATURED_CONSTEXPR14
1411 throw std::invalid_argument(
"The given pattern is not a valid alternative");
1416 return !c.alt_enabled
1417 ?
throw std::invalid_argument(
"The use of alternatives is disabled")
1419 ?
throw std::invalid_argument(
"The given pattern is not a valid alternative")
1423 : c.set_enabled && *
p == c.set_open &&
1427 pend, c, state, depth)
1432 c, state, depth - 1)
1442 :
throw std::logic_error(
1443 "The program execution should never end up here throwing "
1448 template <
typename SequenceIterator,
typename PatternIterator,
1450 constexpr match_result<SequenceIterator, PatternIterator>
match(
1451 SequenceIterator s, SequenceIterator send, PatternIterator
p, PatternIterator pend,
1453 const EqualTo& equal_to = EqualTo(),
bool partial =
false,
bool escape =
false);
1454 template <
typename SequenceIterator,
typename PatternIterator,
1457 SequenceIterator s, SequenceIterator send, PatternIterator p1, PatternIterator p1end,
1458 PatternIterator p2, PatternIterator p2end,
1460 const EqualTo& equal_to = EqualTo(),
bool partial =
false)
1462 #if cfg_HAS_CONSTEXPR14
1463 auto result1 =
match(s, send, p1, p1end, c, equal_to,
true);
1466 auto result2 =
match(result1.s, send, p2, p2end, c, equal_to, partial);
1477 return match_alt(s, send, p1,
alt_sub_end(p1, p2, c), p2, p2end, c, equal_to, partial);
1479 return match(s, send, p1, p1end, c, equal_to,
true) &&
1480 match(
match(s, send, p1, p1end, c, equal_to,
true).s, send, p2, p2end, c, equal_to,
1482 ?
match(
match(s, send, p1, p1end, c, equal_to,
true).s, send, p2, p2end, c, equal_to,
1487 p2end, c, equal_to, partial);
1490 template <
typename SequenceIterator,
typename PatternIterator,
typename EqualTo>
1492 SequenceIterator s, SequenceIterator send, PatternIterator
p, PatternIterator pend,
1496 #if cfg_HAS_CONSTEXPR14
1503 if (s == send || !equal_to(*s, *
p))
1509 if (*
p == c.anything)
1511 auto result =
match(s, send,
cx::next(
p), pend, c, equal_to, partial);
1532 return match(s, send,
cx::next(
p), pend, c, equal_to, partial,
true);
1543 pend, c, equal_to, partial);
1549 c, equal_to, partial);
1551 if (s == send || !equal_to(*s, *
p))
1560 ? s == send || !equal_to(*s, *
p)
1574 : c.set_enabled && *
p == c.set_open &&
1585 pend, c, equal_to, partial)
1586 : c.alt_enabled && *
p == c.alt_open &&
1597 pend, c, equal_to, partial)
1598 : s == send || !equal_to(*s, *
p)
1601 c, equal_to, partial);
1605 template <
typename Sequence,
typename Pattern,
typename EqualTo = cx::equal_to<
void>>
1607 Sequence&& sequence, Pattern&& pattern,
1609 const EqualTo& equal_to = EqualTo())
1616 template <
typename Sequence,
typename Pattern,
typename EqualTo = cx::equal_to<
void>,
1617 typename =
typename std::enable_if<!std::is_same<EqualTo, cards_type>::value>::type>
1619 Sequence&& sequence, Pattern&& pattern,
const EqualTo& equal_to)
1621 return match(std::forward<Sequence>(sequence), std::forward<Pattern>(pattern),
1626 #ifndef WILDCARDS_MATCHER_HPP
1627 #define WILDCARDS_MATCHER_HPP
1629 #include <type_traits>
1631 #ifndef CX_STRING_VIEW_HPP
1632 #define CX_STRING_VIEW_HPP
1635 #ifndef CX_ALGORITHM_HPP
1636 #define CX_ALGORITHM_HPP
1639 template <
typename Iterator1,
typename Iterator2>
1640 constexpr
bool equal(Iterator1 first1, Iterator1 last1, Iterator2 first2, Iterator2 last2)
1642 #if cfg_HAS_CONSTEXPR14
1643 while (first1 != last1 && first2 != last2 && *first1 == *first2)
1647 return first1 == last1 && first2 == last2;
1649 return first1 != last1 && first2 != last2 && *first1 == *first2
1650 ?
equal(first1 + 1, last1, first2 + 1, last2)
1651 : first1 == last1 && first2 == last2;
1658 template <
typename T>
1664 template <std::
size_t N>
1691 constexpr
const T*
end()
const
1703 template <
typename T>
1708 template <
typename T>
1711 return !(lhs == rhs);
1713 template <
typename T>
1719 template <
typename T, std::
size_t N>
1722 return {str, N - 1};
1724 template <
typename T>
1756 template <
typename Pattern,
typename EqualTo = cx::equal_to<
void>>
1762 const EqualTo& equal_to = EqualTo())
1769 constexpr
matcher(Pattern&& pattern,
const EqualTo& equal_to)
1772 c_{cards<container_item_t<Pattern>>()},
1776 template <
typename Sequence>
1778 Sequence&& sequence)
const
1791 template <
typename Pattern,
typename EqualTo = cx::equal_to<
void>>
1795 const EqualTo& equal_to = EqualTo())
1799 template <
typename Pattern,
typename EqualTo = cx::equal_to<
void>,
1800 typename =
typename std::enable_if<!std::is_same<EqualTo, cards_type>::value>::type>
1807 constexpr
auto operator"" _wc(
const char* str, std::size_t s)
1812 constexpr
auto operator"" _wc(
const char16_t* str, std::size_t s)
1817 constexpr
auto operator"" _wc(
const char32_t* str, std::size_t s)
1822 constexpr
auto operator"" _wc(
const wchar_t* str, std::size_t s)