43#ifndef _GLIBCXX_FUNCTIONAL
44#define _GLIBCXX_FUNCTIONAL 1
47#pragma GCC system_header
53#if __cplusplus >= 201103L
55#define __glibcxx_want_boyer_moore_searcher
56#define __glibcxx_want_bind_front
57#define __glibcxx_want_bind_back
58#define __glibcxx_want_constexpr_functional
59#define __glibcxx_want_copyable_function
60#define __glibcxx_want_function_ref
61#define __glibcxx_want_invoke
62#define __glibcxx_want_invoke_r
63#define __glibcxx_want_move_only_function
64#define __glibcxx_want_not_fn
65#define __glibcxx_want_ranges
66#define __glibcxx_want_reference_wrapper
67#define __glibcxx_want_common_reference_wrapper
68#define __glibcxx_want_transparent_operators
78#if __cplusplus >= 201703L
86#if __cplusplus >= 202002L
87# include <bits/binders.h>
91#if __glibcxx_move_only_function || __glibcxx_copyable_function || \
92 __glibcxx_function_ref
98namespace std _GLIBCXX_VISIBILITY(default)
100_GLIBCXX_BEGIN_NAMESPACE_VERSION
108#ifdef __cpp_lib_invoke
121 template<
typename _Callable,
typename... _Args>
122 inline _GLIBCXX20_CONSTEXPR invoke_result_t<_Callable, _Args...>
123 invoke(_Callable&& __fn, _Args&&... __args)
124 noexcept(is_nothrow_invocable_v<_Callable, _Args...>)
131#ifdef __cpp_lib_invoke_r
140 template<
typename _Res,
typename _Callable,
typename... _Args>
141 requires is_invocable_r_v<_Res, _Callable, _Args...>
143 invoke_r(_Callable&& __fn, _Args&&... __args)
144 noexcept(is_nothrow_invocable_r_v<_Res, _Callable, _Args...>)
153#if __cplusplus >= 201103L
154 template<
typename _MemFunPtr,
157 :
public _Mem_fn_traits<_MemFunPtr>::__maybe_type
159 using _Traits = _Mem_fn_traits<_MemFunPtr>;
161 using _Arity =
typename _Traits::__arity;
162 using _Varargs =
typename _Traits::__vararg;
164 template<
typename _Func,
typename... _BoundArgs>
165 friend struct _Bind_check_arity;
171 using result_type =
typename _Traits::__result_type;
174 _Mem_fn_base(_MemFunPtr __pmf) noexcept : _M_pmf(__pmf) { }
176 template<
typename... _Args>
179 operator()(_Args&&... __args)
const
187 template<
typename _MemObjPtr>
188 class _Mem_fn_base<_MemObjPtr, false>
190 using _Arity = integral_constant<size_t, 0>;
193 template<
typename _Func,
typename... _BoundArgs>
194 friend struct _Bind_check_arity;
200 _Mem_fn_base(_MemObjPtr __pm) noexcept : _M_pm(__pm) { }
202 template<
typename _Tp>
205 operator()(_Tp&& __obj)
const
211 template<
typename _MemberPo
inter>
214 template<
typename _Res,
typename _Class>
215 struct _Mem_fn<_Res _Class::*>
216 : _Mem_fn_base<_Res _Class::*>
218 using _Mem_fn_base<_Res _Class::*>::_Mem_fn_base;
247 template<
typename _Tp,
typename _Class>
249 inline _Mem_fn<_Tp _Class::*>
252 return _Mem_fn<_Tp _Class::*>(__pm);
266 template<
typename _Tp>
278 template<
typename _Tp>
283#if __cplusplus > 201402L
284 template <
typename _Tp>
inline constexpr bool is_bind_expression_v
286 template <
typename _Tp>
inline constexpr int is_placeholder_v
287 = is_placeholder<_Tp>::value;
301#if __cpp_inline_variables
302# define _GLIBCXX_PLACEHOLDER inline
304# define _GLIBCXX_PLACEHOLDER extern
337#undef _GLIBCXX_PLACEHOLDER
359 template<std::
size_t __i,
typename _Tuple>
360 using _Safe_tuple_element_t
361 =
typename enable_if<(__i < tuple_size<_Tuple>::value),
362 tuple_element<__i, _Tuple>>::type::type;
375 template<
typename _Arg,
376 bool _IsBindExp = is_bind_expression<_Arg>::value,
377 bool _IsPlaceholder = (is_placeholder<_Arg>::value > 0)>
385 template<
typename _Tp>
386 class _Mu<reference_wrapper<_Tp>, false, false>
393 template<
typename _CVRef,
typename _Tuple>
396 operator()(_CVRef& __arg, _Tuple&)
const volatile
397 {
return __arg.get(); }
406 template<
typename _Arg>
407 class _Mu<_Arg, true, false>
410 template<
typename _CVArg,
typename... _Args>
413 operator()(_CVArg& __arg,
414 tuple<_Args...>& __tuple)
const volatile
415 ->
decltype(__arg(declval<_Args>()...))
418 typedef typename _Build_index_tuple<
sizeof...(_Args)>::__type
420 return this->__call(__arg, __tuple, _Indexes());
426 template<
typename _CVArg,
typename... _Args, std::size_t... _Indexes>
429 __call(_CVArg& __arg, tuple<_Args...>& __tuple,
430 const _Index_tuple<_Indexes...>&)
const volatile
431 ->
decltype(__arg(declval<_Args>()...))
433 return __arg(std::get<_Indexes>(
std::move(__tuple))...);
442 template<
typename _Arg>
443 class _Mu<_Arg, false, true>
446 template<
typename _Tuple>
448 _Safe_tuple_element_t<(is_placeholder<_Arg>::value - 1), _Tuple>&&
449 operator()(
const volatile _Arg&, _Tuple& __tuple)
const volatile
452 ::std::get<(is_placeholder<_Arg>::value - 1)>(
std::move(__tuple));
461 template<
typename _Arg>
462 class _Mu<_Arg, false, false>
465 template<
typename _CVArg,
typename _Tuple>
468 operator()(_CVArg&& __arg, _Tuple&)
const volatile
473 template<std::size_t _Ind,
typename... _Tp>
476 -> __tuple_element_t<_Ind,
tuple<_Tp...>>
volatile&
477 {
return std::get<_Ind>(
const_cast<tuple<_Tp...
>&>(__tuple)); }
480 template<std::size_t _Ind,
typename... _Tp>
483 -> __tuple_element_t<_Ind,
tuple<_Tp...>>
const volatile&
484 {
return std::get<_Ind>(
const_cast<const tuple<_Tp...
>&>(__tuple)); }
488#if __cplusplus == 201703L && _GLIBCXX_USE_DEPRECATED
489# define _GLIBCXX_VOLATILE_BIND
492# define _GLIBCXX_DEPR_BIND \
493 [[deprecated("std::bind does not support volatile in C++17")]]
494#elif __cplusplus < 201703L
495# define _GLIBCXX_VOLATILE_BIND
496# define _GLIBCXX_DEPR_BIND
500 template<
typename _Signature>
503 template<
typename _Functor,
typename... _Bound_args>
504 class _Bind<_Functor(_Bound_args...)>
505 :
public _Weak_result_type<_Functor>
507 typedef typename _Build_index_tuple<
sizeof...(_Bound_args)>::__type
511 tuple<_Bound_args...> _M_bound_args;
514 template<
typename _Result,
typename... _Args, std::size_t... _Indexes>
520 _Mu<_Bound_args>()(std::get<_Indexes>(_M_bound_args), __args)...
525 template<
typename _Result,
typename... _Args, std::size_t... _Indexes>
531 _Mu<_Bound_args>()(std::get<_Indexes>(_M_bound_args), __args)...
535#ifdef _GLIBCXX_VOLATILE_BIND
537 template<
typename _Result,
typename... _Args, std::size_t... _Indexes>
539 __call_v(tuple<_Args...>&& __args,
540 _Index_tuple<_Indexes...>)
volatile
543 _Mu<_Bound_args>()(__volget<_Indexes>(_M_bound_args), __args)...
548 template<
typename _Result,
typename... _Args, std::size_t... _Indexes>
550 __call_c_v(tuple<_Args...>&& __args,
551 _Index_tuple<_Indexes...>)
const volatile
554 _Mu<_Bound_args>()(__volget<_Indexes>(_M_bound_args), __args)...
559 template<
typename _BoundArg,
typename _CallArgs>
560 using _Mu_type =
decltype(
561 _Mu<typename remove_cv<_BoundArg>::type>()(
564 template<
typename _Fn,
typename _CallArgs,
typename... _BArgs>
566 = __invoke_result_t<_Fn&, _Mu_type<_BArgs, _CallArgs>&&...>;
568 template<
typename _CallArgs>
569 using _Res_type = _Res_type_impl<_Functor, _CallArgs, _Bound_args...>;
571 template<
typename _CallArgs>
572 using __dependent =
typename
573 enable_if<bool(tuple_size<_CallArgs>::value+1), _Functor>::type;
575 template<
typename _CallArgs,
template<
class>
class __cv_quals>
576 using _Res_type_cv = _Res_type_impl<
577 typename __cv_quals<__dependent<_CallArgs>>::type,
579 typename __cv_quals<_Bound_args>::type...>;
582 template<
typename... _Args>
583 explicit _GLIBCXX20_CONSTEXPR
584 _Bind(
const _Functor& __f, _Args&&... __args)
585 : _M_f(__f), _M_bound_args(std::
forward<_Args>(__args)...)
588 template<
typename... _Args>
589 explicit _GLIBCXX20_CONSTEXPR
590 _Bind(_Functor&& __f, _Args&&... __args)
591 : _M_f(std::
move(__f)), _M_bound_args(std::
forward<_Args>(__args)...)
594 _Bind(
const _Bind&) =
default;
595 _Bind(_Bind&&) =
default;
598 template<
typename... _Args,
599 typename _Result = _Res_type<tuple<_Args...>>>
602 operator()(_Args&&... __args)
604 return this->__call<_Result>(
610 template<
typename... _Args,
611 typename _Result = _Res_type_cv<tuple<_Args...>, add_const>>
614 operator()(_Args&&... __args)
const
616 return this->__call_c<_Result>(
621#ifdef _GLIBCXX_VOLATILE_BIND
623 template<
typename... _Args,
624 typename _Result = _Res_type_cv<tuple<_Args...>, add_volatile>>
627 operator()(_Args&&... __args)
volatile
629 return this->__call_v<_Result>(
635 template<
typename... _Args,
636 typename _Result = _Res_type_cv<tuple<_Args...>, add_cv>>
639 operator()(_Args&&... __args)
const volatile
641 return this->__call_c_v<_Result>(
649 template<
typename _Result,
typename _Signature>
652 template<
typename _Result,
typename _Functor,
typename... _Bound_args>
655 typedef typename _Build_index_tuple<
sizeof...(_Bound_args)>::__type
659 tuple<_Bound_args...> _M_bound_args;
662 template<
typename _Res,
typename... _Args, std::size_t... _Indexes>
667 return std::__invoke_r<_Res>(_M_f, _Mu<_Bound_args>()
668 (std::get<_Indexes>(_M_bound_args), __args)...);
672 template<
typename _Res,
typename... _Args, std::size_t... _Indexes>
677 return std::__invoke_r<_Res>(_M_f, _Mu<_Bound_args>()
678 (std::get<_Indexes>(_M_bound_args), __args)...);
681#ifdef _GLIBCXX_VOLATILE_BIND
683 template<
typename _Res,
typename... _Args, std::size_t... _Indexes>
687 return std::__invoke_r<_Res>(_M_f, _Mu<_Bound_args>()
688 (__volget<_Indexes>(_M_bound_args), __args)...);
692 template<
typename _Res,
typename... _Args, std::size_t... _Indexes>
695 _Index_tuple<_Indexes...>)
const volatile
697 return std::__invoke_r<_Res>(_M_f, _Mu<_Bound_args>()
698 (__volget<_Indexes>(_M_bound_args), __args)...);
703 typedef _Result result_type;
705 template<
typename... _Args>
706 explicit _GLIBCXX20_CONSTEXPR
711 template<
typename... _Args>
712 explicit _GLIBCXX20_CONSTEXPR
721 template<
typename... _Args>
724 operator()(_Args&&... __args)
726 return this->__call<_Result>(
732 template<
typename... _Args>
735 operator()(_Args&&... __args)
const
737 return this->__call<_Result>(
742#ifdef _GLIBCXX_VOLATILE_BIND
744 template<
typename... _Args>
747 operator()(_Args&&... __args)
volatile
749 return this->__call<_Result>(
755 template<
typename... _Args>
758 operator()(_Args&&... __args)
const volatile
760 return this->__call<_Result>(
765 template<
typename... _Args>
766 void operator()(_Args&&...)
const volatile =
delete;
770#undef _GLIBCXX_VOLATILE_BIND
771#undef _GLIBCXX_DEPR_BIND
777 template<
typename _Signature>
785 template<
typename _Signature>
793 template<
typename _Signature>
801 template<
typename _Signature>
809 template<
typename _Result,
typename _Signature>
817 template<
typename _Result,
typename _Signature>
825 template<
typename _Result,
typename _Signature>
833 template<
typename _Result,
typename _Signature>
837 template<
typename _Func,
typename... _BoundArgs>
838 struct _Bind_check_arity { };
840 template<
typename _Ret,
typename... _Args,
typename... _BoundArgs>
841 struct _Bind_check_arity<_Ret (*)(_Args...), _BoundArgs...>
843 static_assert(
sizeof...(_BoundArgs) ==
sizeof...(_Args),
844 "Wrong number of arguments for function");
847 template<
typename _Ret,
typename... _Args,
typename... _BoundArgs>
848 struct _Bind_check_arity<_Ret (*)(_Args..., ...), _BoundArgs...>
850 static_assert(
sizeof...(_BoundArgs) >=
sizeof...(_Args),
851 "Wrong number of arguments for function");
854 template<
typename _Tp,
typename _Class,
typename... _BoundArgs>
855 struct _Bind_check_arity<_Tp _Class::*, _BoundArgs...>
857 using _Arity =
typename _Mem_fn<_Tp _Class::*>::_Arity;
858 using _Varargs =
typename _Mem_fn<_Tp _Class::*>::_Varargs;
859 static_assert(_Varargs::value
860 ?
sizeof...(_BoundArgs) >= _Arity::value + 1
861 :
sizeof...(_BoundArgs) == _Arity::value + 1,
862 "Wrong number of arguments for pointer-to-member");
868 template<typename _Tp, typename _Tp2 = typename decay<_Tp>::type>
869 using __is_socketlike = __or_<is_integral<_Tp2>,
is_enum<_Tp2>>;
871 template<
bool _SocketLike,
typename _Func,
typename... _BoundArgs>
873 : _Bind_check_arity<typename decay<_Func>::type, _BoundArgs...>
875 typedef typename decay<_Func>::type __func_type;
876 typedef _Bind<__func_type(
typename decay<_BoundArgs>::type...)> type;
882 template<
typename _Func,
typename... _BoundArgs>
883 struct _Bind_helper<true, _Func, _BoundArgs...>
891 template<
typename _Func,
typename... _BoundArgs>
892 inline _GLIBCXX20_CONSTEXPR
typename
893 _Bind_helper<__is_socketlike<_Func>::value, _Func, _BoundArgs...>::type
894 bind(_Func&& __f, _BoundArgs&&... __args)
896 typedef _Bind_helper<
false, _Func, _BoundArgs...> __helper_type;
901 template<
typename _Result,
typename _Func,
typename... _BoundArgs>
902 struct _Bindres_helper
903 : _Bind_check_arity<typename decay<_Func>::type, _BoundArgs...>
905 typedef typename decay<_Func>::type __functor_type;
906 typedef _Bind_result<_Result,
907 __functor_type(
typename decay<_BoundArgs>::type...)>
916 template<
typename _Result,
typename _Func,
typename... _BoundArgs>
917 inline _GLIBCXX20_CONSTEXPR
918 typename _Bindres_helper<_Result, _Func, _BoundArgs...>::type
919 bind(_Func&& __f, _BoundArgs&&... __args)
921 typedef _Bindres_helper<_Result, _Func, _BoundArgs...> __helper_type;
926#if __cpp_lib_bind_front >= 202306L || __cpp_lib_bind_back >= 202306L
930 using _Fn =
const decltype(__fn)&;
931 template <
typename... _Args>
932 requires is_invocable_v<_Fn, _Args...>
933 constexpr static decltype(
auto)
934 operator()(_Args&&... __args)
935 noexcept(is_nothrow_invocable_v<_Fn, _Args...>)
940#ifdef __cpp_lib_bind_front
950 template<
typename _Fn,
typename... _Args>
951 constexpr _Bind_front_t<_Fn, _Args...>
952 bind_front(_Fn&& __fn, _Args&&... __args)
953 noexcept(is_nothrow_constructible_v<_Bind_front_t<_Fn, _Args...>,
960#if __cpp_lib_bind_front >= 202306L
970 template<
auto __fn,
typename... _BindArgs>
971 constexpr decltype(
auto)
972 bind_front(_BindArgs&&... __bind_args)
973 noexcept(__and_v<is_nothrow_constructible<_BindArgs>...>)
975 using _Fn =
decltype(__fn);
976 if constexpr (is_pointer_v<_Fn> || is_member_pointer_v<_Fn>)
977 static_assert(__fn !=
nullptr);
979 if constexpr (
sizeof...(_BindArgs) == 0)
980 return _Bind_fn_t<__fn>{};
982 return _Bind_front_t<_Bind_fn_t<__fn>, _BindArgs...>(0,
989#ifdef __cpp_lib_bind_back
999 template<
typename _Fn,
typename... _Args>
1000 constexpr _Bind_back_t<_Fn, _Args...>
1001 bind_back(_Fn&& __fn, _Args&&... __args)
1002 noexcept(is_nothrow_constructible_v<_Bind_back_t<_Fn, _Args...>,
1003 int, _Fn, _Args...>)
1009#if __cpp_lib_bind_back >= 202306L
1020 template<
auto __fn,
typename... _BindArgs>
1021 constexpr decltype(
auto)
1022 bind_back(_BindArgs&&... __bind_args)
1023 noexcept(__and_v<is_nothrow_constructible<_BindArgs>...>)
1025 using _Fn =
decltype(__fn);
1026 if constexpr (is_pointer_v<_Fn> || is_member_pointer_v<_Fn>)
1027 static_assert(__fn !=
nullptr);
1029 if constexpr (
sizeof...(_BindArgs) == 0)
1030 return _Bind_fn_t<__fn>{};
1032 return _Bind_back_t<_Bind_fn_t<__fn>, _BindArgs...>(0,
1038#if __cplusplus >= 201402L
1040 template<
typename _Fn>
1043 template<
typename _Fn2,
typename... _Args>
1044 using __inv_res_t =
typename __invoke_result<_Fn2, _Args...>
::type;
1046 template<
typename _Tp>
1051 template<
typename _Fn2>
1053 _Not_fn(_Fn2&& __fn,
int)
1056 _Not_fn(
const _Not_fn& __fn) =
default;
1057 _Not_fn(_Not_fn&& __fn) =
default;
1058 ~_Not_fn() =
default;
1060#if _GLIBCXX_EXPLICIT_THIS_PARAMETER
1061# pragma GCC diagnostic push
1062# pragma GCC diagnostic ignored "-Wc++23-extensions"
1063 template<
typename _Self,
typename... _Args>
1064 _GLIBCXX20_CONSTEXPR
1065 decltype(_S_not<__inv_res_t<__like_t<_Self, _Fn>, _Args...>>())
1066 operator()(
this _Self&& __self, _Args&&... __args)
1067 noexcept(__is_nothrow_invocable<__like_t<_Self, _Fn>, _Args...>::value
1068 &&
noexcept(_S_not<__inv_res_t<__like_t<_Self, _Fn>, _Args...>>()))
1070 return !
std::__invoke(__like_t<_Self, _Not_fn>(__self)._M_fn,
1073# pragma GCC diagnostic pop
1078#define _GLIBCXX_NOT_FN_CALL_OP( _QUALS ) \
1079 template<typename... _Args, \
1080 typename = enable_if_t<__is_invocable<_Fn _QUALS, _Args...>::value>> \
1081 _GLIBCXX20_CONSTEXPR \
1082 decltype(_S_not<__inv_res_t<_Fn _QUALS, _Args...>>()) \
1083 operator()(_Args&&... __args) _QUALS \
1084 noexcept(__is_nothrow_invocable<_Fn _QUALS, _Args...>::value \
1085 && noexcept(_S_not<__inv_res_t<_Fn _QUALS, _Args...>>())) \
1087 return !std::__invoke(std::forward< _Fn _QUALS >(_M_fn), \
1088 std::forward<_Args>(__args)...); \
1091 template<typename... _Args, \
1092 typename = enable_if_t<!__is_invocable<_Fn _QUALS, _Args...>::value>> \
1093 void operator()(_Args&&... __args) _QUALS = delete;
1095 _GLIBCXX_NOT_FN_CALL_OP( & )
1096 _GLIBCXX_NOT_FN_CALL_OP(
const & )
1097 _GLIBCXX_NOT_FN_CALL_OP( && )
1098 _GLIBCXX_NOT_FN_CALL_OP(
const && )
1099#undef _GLIBCXX_NOT_FN_CALL_OP
1106 template<
typename _Tp,
typename _Pred>
1109 template<
typename _Tp>
1110 struct __is_byte_like<_Tp, equal_to<_Tp>>
1111 : __bool_constant<sizeof(_Tp) == 1 && is_integral<_Tp>::value> { };
1113 template<
typename _Tp>
1114 struct __is_byte_like<_Tp,
equal_to<void>>
1115 : __bool_constant<sizeof(_Tp) == 1 && is_integral<_Tp>::value> { };
1117#if __cplusplus >= 201703L
1119 enum class byte :
unsigned char;
1122 struct __is_byte_like<byte,
equal_to<byte>>
1126 struct __is_byte_like<byte,
equal_to<void>>
1131#ifdef __cpp_lib_not_fn
1144 template<
typename _Fn>
1145 _GLIBCXX20_CONSTEXPR
1148 noexcept(std::is_nothrow_constructible<std::decay_t<_Fn>, _Fn&&>::value)
1153#if __cpp_lib_not_fn >= 202306L
1167 constexpr decltype(
auto)
1170 using _Fn =
decltype(__fn);
1171 if constexpr (is_pointer_v<_Fn> || is_member_pointer_v<_Fn>)
1172 static_assert(__fn !=
nullptr);
1173 return []<
typename... _Args>(_Args&&... __args)
static
1184#if __cplusplus >= 201703L
1187 template<
typename _ForwardIterator1,
typename _BinaryPredicate = equal_to<>>
1188 class default_searcher
1191 _GLIBCXX20_CONSTEXPR
1192 default_searcher(_ForwardIterator1 __pat_first,
1193 _ForwardIterator1 __pat_last,
1194 _BinaryPredicate __pred = _BinaryPredicate())
1195 : _M_m(__pat_first, __pat_last, std::
move(__pred))
1198 template<
typename _ForwardIterator2>
1199 _GLIBCXX20_CONSTEXPR
1201 operator()(_ForwardIterator2 __first, _ForwardIterator2 __last)
const
1203 _ForwardIterator2 __first_ret =
1204 std::search(__first, __last, std::get<0>(_M_m), std::get<1>(_M_m),
1207 if (__ret.first != __last)
1209 std::get<1>(_M_m)));
1214 tuple<_ForwardIterator1, _ForwardIterator1, _BinaryPredicate> _M_m;
1217#ifdef __cpp_lib_boyer_moore_searcher
1219 template<
typename _Key,
typename _Tp,
typename _Hash,
typename _Pred>
1220 struct __boyer_moore_map_base
1222 template<
typename _RAIter>
1223 __boyer_moore_map_base(_RAIter __pat,
size_t __patlen,
1224 _Hash&& __hf, _Pred&& __pred)
1225 : _M_bad_char{ __patlen, std::
move(__hf), std::
move(__pred) }
1228 for (__diff_type __i = 0; __i < __patlen - 1; ++__i)
1229 _M_bad_char[__pat[__i]] = __patlen - 1 - __i;
1232 using __diff_type = _Tp;
1235 _M_lookup(_Key __key, __diff_type __not_found)
const
1237 auto __iter = _M_bad_char.find(__key);
1238 if (__iter == _M_bad_char.end())
1240 return __iter->second;
1244 _M_pred()
const {
return _M_bad_char.key_eq(); }
1246 _GLIBCXX_STD_C::unordered_map<_Key, _Tp, _Hash, _Pred> _M_bad_char;
1249 template<
typename _Tp,
size_t _Len,
typename _Pred>
1250 struct __boyer_moore_array_base
1252 template<
typename _RAIter,
typename _Unused>
1253 __boyer_moore_array_base(_RAIter __pat,
size_t __patlen,
1254 _Unused&&, _Pred&& __pred)
1255 : _M_bad_char{ array<_Tp, _Len>{},
std::move(__pred) }
1257 std::get<0>(_M_bad_char).fill(__patlen);
1259 for (__diff_type __i = 0; __i < __patlen - 1; ++__i)
1261 auto __ch = __pat[__i];
1263 auto __uch =
static_cast<_UCh
>(__ch);
1264 std::get<0>(_M_bad_char)[__uch] = __patlen - 1 - __i;
1268 using __diff_type = _Tp;
1270 template<
typename _Key>
1272 _M_lookup(_Key __key, __diff_type __not_found)
const
1277 return std::get<0>(_M_bad_char)[__ukey];
1281 _M_pred()
const {
return std::get<1>(_M_bad_char); }
1288 template<
typename _RAIter,
typename _Hash,
typename _Pred,
1289 typename _Val =
typename iterator_traits<_RAIter>::value_type,
1290 typename _Diff =
typename iterator_traits<_RAIter>::difference_type>
1291 using __boyer_moore_base_t
1292 = __conditional_t<__is_byte_like<_Val, _Pred>::value,
1293 __boyer_moore_array_base<_Diff, 256, _Pred>,
1294 __boyer_moore_map_base<_Val, _Diff, _Hash, _Pred>>;
1296 template<
typename _RAIter,
typename _Hash
1297 = hash<typename iterator_traits<_RAIter>::value_type>,
1298 typename _BinaryPredicate = equal_to<>>
1299 class boyer_moore_searcher
1300 : __boyer_moore_base_t<_RAIter, _Hash, _BinaryPredicate>
1302 using _Base = __boyer_moore_base_t<_RAIter, _Hash, _BinaryPredicate>;
1303 using typename _Base::__diff_type;
1306 boyer_moore_searcher(_RAIter __pat_first, _RAIter __pat_last,
1307 _Hash __hf = _Hash(),
1308 _BinaryPredicate __pred = _BinaryPredicate());
1310 template<
typename _RandomAccessIterator2>
1311 pair<_RandomAccessIterator2, _RandomAccessIterator2>
1312 operator()(_RandomAccessIterator2 __first,
1313 _RandomAccessIterator2 __last)
const;
1317 _M_is_prefix(_RAIter __word, __diff_type __len,
1320 const auto& __pred = this->_M_pred();
1321 __diff_type __suffixlen = __len - __pos;
1322 for (__diff_type __i = 0; __i < __suffixlen; ++__i)
1323 if (!__pred(__word[__i], __word[__pos + __i]))
1329 _M_suffix_length(_RAIter __word, __diff_type __len,
1332 const auto& __pred = this->_M_pred();
1333 __diff_type __i = 0;
1334 while (__pred(__word[__pos - __i], __word[__len - 1 - __i])
1342 template<
typename _Tp>
1344 _M_bad_char_shift(_Tp __c)
const
1345 {
return this->_M_lookup(__c, _M_pat_end - _M_pat); }
1349 _GLIBCXX_STD_C::vector<__diff_type> _M_good_suffix;
1352 template<
typename _RAIter,
typename _Hash
1353 = hash<typename iterator_traits<_RAIter>::value_type>,
1354 typename _BinaryPredicate = equal_to<>>
1355 class boyer_moore_horspool_searcher
1356 : __boyer_moore_base_t<_RAIter, _Hash, _BinaryPredicate>
1358 using _Base = __boyer_moore_base_t<_RAIter, _Hash, _BinaryPredicate>;
1359 using typename _Base::__diff_type;
1362 boyer_moore_horspool_searcher(_RAIter __pat,
1364 _Hash __hf = _Hash(),
1365 _BinaryPredicate __pred
1366 = _BinaryPredicate())
1367 : _Base(__pat, __pat_end - __pat, std::
move(__hf), std::
move(__pred)),
1368 _M_pat(__pat), _M_pat_end(__pat_end)
1371 template<
typename _RandomAccessIterator2>
1372 pair<_RandomAccessIterator2, _RandomAccessIterator2>
1373 operator()(_RandomAccessIterator2 __first,
1374 _RandomAccessIterator2 __last)
const
1376#ifdef __glibcxx_concepts
1379 static_assert(is_same_v<iter_value_t<_RAIter>,
1380 iter_value_t<_RandomAccessIterator2>>);
1382 const auto& __pred = this->_M_pred();
1383 auto __patlen = _M_pat_end - _M_pat;
1386 auto __len = __last - __first;
1387 while (__len >= __patlen)
1389 for (
auto __scan = __patlen - 1;
1390 __pred(__first[__scan], _M_pat[__scan]); --__scan)
1393 auto __shift = _M_bad_char_shift(__first[__patlen - 1]);
1401 template<
typename _Tp>
1403 _M_bad_char_shift(_Tp __c)
const
1404 {
return this->_M_lookup(__c, _M_pat_end - _M_pat); }
1410 template<
typename _RAIter,
typename _Hash,
typename _BinaryPredicate>
1411 boyer_moore_searcher<_RAIter, _Hash, _BinaryPredicate>::
1412 boyer_moore_searcher(_RAIter __pat, _RAIter __pat_end,
1413 _Hash __hf, _BinaryPredicate __pred)
1414 : _Base(__pat, __pat_end - __pat,
std::
move(__hf),
std::
move(__pred)),
1415 _M_pat(__pat), _M_pat_end(__pat_end), _M_good_suffix(__pat_end - __pat)
1417 auto __patlen = __pat_end - __pat;
1420 __diff_type __last_prefix = __patlen - 1;
1421 for (__diff_type __p = __patlen - 1; __p >= 0; --__p)
1423 if (_M_is_prefix(__pat, __patlen, __p + 1))
1424 __last_prefix = __p + 1;
1425 _M_good_suffix[__p] = __last_prefix + (__patlen - 1 - __p);
1427 for (__diff_type __p = 0; __p < __patlen - 1; ++__p)
1429 auto __slen = _M_suffix_length(__pat, __patlen, __p);
1430 auto __pos = __patlen - 1 - __slen;
1431 if (!__pred(__pat[__p - __slen], __pat[__pos]))
1432 _M_good_suffix[__pos] = __patlen - 1 - __p + __slen;
1436 template<
typename _RAIter,
typename _Hash,
typename _BinaryPredicate>
1437 template<
typename _RandomAccessIterator2>
1439 boyer_moore_searcher<_RAIter, _Hash, _BinaryPredicate>::
1440 operator()(_RandomAccessIterator2 __first,
1441 _RandomAccessIterator2 __last)
const
1443#ifdef __glibcxx_concepts
1446 static_assert(is_same_v<iter_value_t<_RAIter>,
1447 iter_value_t<_RandomAccessIterator2>>);
1449 auto __patlen = _M_pat_end - _M_pat;
1452 const auto& __pred = this->_M_pred();
1453 __diff_type __i = __patlen - 1;
1454 auto __stringlen = __last - __first;
1455 while (__i < __stringlen)
1457 __diff_type __j = __patlen - 1;
1458 while (__j >= 0 && __pred(__first[__i], _M_pat[__j]))
1465 const auto __match = __first + __diff_type(__i + 1);
1468 __i +=
std::max(_M_bad_char_shift(__first[__i]),
1469 _M_good_suffix[__j]);
1479_GLIBCXX_END_NAMESPACE_VERSION
__bool_constant< true > true_type
The type used as a compile-time boolean with true value.
typename make_unsigned< _Tp >::type make_unsigned_t
Alias template for make_unsigned.
__bool_constant< false > false_type
The type used as a compile-time boolean with false value.
pair(_T1, _T2) -> pair< _T1, _T2 >
Two pairs are equal iff their members are equal.
constexpr pair< typename __decay_and_strip< _T1 >::__type, typename __decay_and_strip< _T2 >::__type > make_pair(_T1 &&__x, _T2 &&__y)
A convenience wrapper for creating a pair from two objects.
auto declval() noexcept -> decltype(__declval< _Tp >(0))
constexpr tuple< _Elements &&... > forward_as_tuple(_Elements &&... __args) noexcept
Create a tuple of lvalue or rvalue references to the arguments.
constexpr std::remove_reference< _Tp >::type && move(_Tp &&__t) noexcept
Convert a value to an rvalue.
constexpr __invoke_result< _Callable, _Args... >::type __invoke(_Callable &&__fn, _Args &&... __args) noexcept(__is_nothrow_invocable< _Callable, _Args... >::value)
Invoke a callable object.
constexpr _Tp && forward(typename std::remove_reference< _Tp >::type &__t) noexcept
Forward an lvalue.
constexpr const _Tp & max(const _Tp &, const _Tp &)
This does what you think it does.
constexpr _Mem_fn< _Tp _Class::* > mem_fn(_Tp _Class::*__pm) noexcept
Returns a function object that forwards to the member pointer pointer pm.
constexpr _Bind_helper< __is_socketlike< _Func >::value, _Func, _BoundArgs... >::type bind(_Func &&__f, _BoundArgs &&... __args)
Function template for std::bind.
ISO C++ entities toplevel namespace is std.
constexpr iterator_traits< _InputIterator >::difference_type distance(_InputIterator __first, _InputIterator __last)
A generalization of pointer arithmetic.
constexpr void advance(_InputIterator &__i, _Distance __n)
A generalization of pointer arithmetic.
auto not_fn(_Fn &&__fn) noexcept(std::is_nothrow_constructible< std::decay_t< _Fn >, _Fn && >::value)
[func.not_fn] Function template not_fn
ISO C++ 2011 namespace for std::bind placeholders.
The type of placeholder objects defined by libstdc++.
Trait that identifies a bind expression.
Determines if the given type _Tp is a placeholder in a bind() expression and, if so,...
Type of the function object returned from bind().
Type of the function object returned from bind<R>().
Primary class template, tuple.
is_member_function_pointer
One of the comparison functors.
Struct holding two objects of arbitrary type.