43#ifndef _GLIBCXX_FUNCTIONAL
44#define _GLIBCXX_FUNCTIONAL 1
46#pragma GCC system_header
51#if __cplusplus >= 201103L
61#if __cplusplus >= 201703L
69#if __cplusplus >= 202002L
73#if __cplusplus > 202002L && _GLIBCXX_HOSTED
77#define __glibcxx_want_boyer_moore_searcher
78#define __glibcxx_want_bind_front
79#define __glibcxx_want_bind_back
80#define __glibcxx_want_constexpr_functional
81#define __glibcxx_want_invoke
82#define __glibcxx_want_invoke_r
83#define __glibcxx_want_move_only_function
84#define __glibcxx_want_not_fn
85#define __glibcxx_want_ranges
86#define __glibcxx_want_transparent_operators
91namespace std _GLIBCXX_VISIBILITY(default)
93_GLIBCXX_BEGIN_NAMESPACE_VERSION
101#ifdef __cpp_lib_invoke
114 template<
typename _Callable,
typename... _Args>
115 inline _GLIBCXX20_CONSTEXPR invoke_result_t<_Callable, _Args...>
116 invoke(_Callable&& __fn, _Args&&... __args)
117 noexcept(is_nothrow_invocable_v<_Callable, _Args...>)
120 std::forward<_Args>(__args)...);
124#ifdef __cpp_lib_invoke_r
133 template<
typename _Res,
typename _Callable,
typename... _Args>
134 requires is_invocable_r_v<_Res, _Callable, _Args...>
136 invoke_r(_Callable&& __fn, _Args&&... __args)
137 noexcept(is_nothrow_invocable_r_v<_Res, _Callable, _Args...>)
139 return std::__invoke_r<_Res>(std::forward<_Callable>(__fn),
140 std::forward<_Args>(__args)...);
146#if __cplusplus >= 201103L
147 template<
typename _MemFunPtr,
148 bool __is_mem_fn = is_member_function_pointer<_MemFunPtr>::value>
150 :
public _Mem_fn_traits<_MemFunPtr>::__maybe_type
152 using _Traits = _Mem_fn_traits<_MemFunPtr>;
154 using _Arity =
typename _Traits::__arity;
155 using _Varargs =
typename _Traits::__vararg;
157 template<
typename _Func,
typename... _BoundArgs>
158 friend struct _Bind_check_arity;
164 using result_type =
typename _Traits::__result_type;
167 _Mem_fn_base(_MemFunPtr __pmf) noexcept : _M_pmf(__pmf) { }
169 template<
typename... _Args>
172 operator()(_Args&&... __args)
const
175 ->
decltype(
std::__invoke(_M_pmf, std::forward<_Args>(__args)...))
176 {
return std::__invoke(_M_pmf, std::forward<_Args>(__args)...); }
180 template<
typename _MemObjPtr>
181 class _Mem_fn_base<_MemObjPtr, false>
183 using _Arity = integral_constant<size_t, 0>;
186 template<
typename _Func,
typename... _BoundArgs>
187 friend struct _Bind_check_arity;
193 _Mem_fn_base(_MemObjPtr __pm) noexcept : _M_pm(__pm) { }
195 template<
typename _Tp>
198 operator()(_Tp&& __obj)
const
199 noexcept(
noexcept(
std::__invoke(_M_pm, std::forward<_Tp>(__obj))))
204 template<
typename _MemberPo
inter>
207 template<
typename _Res,
typename _Class>
208 struct _Mem_fn<_Res _Class::*>
209 : _Mem_fn_base<_Res _Class::*>
211 using _Mem_fn_base<_Res _Class::*>::_Mem_fn_base;
240 template<
typename _Tp,
typename _Class>
242 inline _Mem_fn<_Tp _Class::*>
245 return _Mem_fn<_Tp _Class::*>(__pm);
259 template<
typename _Tp>
271 template<
typename _Tp>
276#if __cplusplus > 201402L
277 template <
typename _Tp>
inline constexpr bool is_bind_expression_v
279 template <
typename _Tp>
inline constexpr int is_placeholder_v
288 namespace placeholders
294#if __cpp_inline_variables
295# define _GLIBCXX_PLACEHOLDER inline
297# define _GLIBCXX_PLACEHOLDER extern
330#undef _GLIBCXX_PLACEHOLDER
352 template<std::
size_t __i,
typename _Tuple>
353 using _Safe_tuple_element_t
354 =
typename enable_if<(__i < tuple_size<_Tuple>::value),
355 tuple_element<__i, _Tuple>>::type::type;
368 template<
typename _Arg,
369 bool _IsBindExp = is_bind_expression<_Arg>::value,
370 bool _IsPlaceholder = (is_placeholder<_Arg>::value > 0)>
378 template<
typename _Tp>
379 class _Mu<reference_wrapper<_Tp>, false, false>
386 template<
typename _CVRef,
typename _Tuple>
389 operator()(_CVRef& __arg, _Tuple&)
const volatile
390 {
return __arg.get(); }
399 template<
typename _Arg>
400 class _Mu<_Arg, true, false>
403 template<
typename _CVArg,
typename... _Args>
406 operator()(_CVArg& __arg,
407 tuple<_Args...>& __tuple)
const volatile
408 ->
decltype(__arg(declval<_Args>()...))
411 typedef typename _Build_index_tuple<
sizeof...(_Args)>::__type
413 return this->__call(__arg, __tuple, _Indexes());
419 template<
typename _CVArg,
typename... _Args, std::size_t... _Indexes>
422 __call(_CVArg& __arg, tuple<_Args...>& __tuple,
423 const _Index_tuple<_Indexes...>&)
const volatile
424 ->
decltype(__arg(declval<_Args>()...))
426 return __arg(std::get<_Indexes>(
std::move(__tuple))...);
435 template<
typename _Arg>
436 class _Mu<_Arg, false, true>
439 template<
typename _Tuple>
441 _Safe_tuple_element_t<(is_placeholder<_Arg>::value - 1), _Tuple>&&
442 operator()(
const volatile _Arg&, _Tuple& __tuple)
const volatile
445 ::std::get<(is_placeholder<_Arg>::value - 1)>(
std::move(__tuple));
454 template<
typename _Arg>
455 class _Mu<_Arg, false, false>
458 template<
typename _CVArg,
typename _Tuple>
461 operator()(_CVArg&& __arg, _Tuple&)
const volatile
462 {
return std::forward<_CVArg>(__arg); }
466 template<std::size_t _Ind,
typename... _Tp>
468 __volget(
volatile tuple<_Tp...>& __tuple)
469 -> __tuple_element_t<_Ind, tuple<_Tp...>>
volatile&
470 {
return std::get<_Ind>(
const_cast<tuple<_Tp...
>&>(__tuple)); }
473 template<std::size_t _Ind,
typename... _Tp>
475 __volget(
const volatile tuple<_Tp...>& __tuple)
476 -> __tuple_element_t<_Ind, tuple<_Tp...>>
const volatile&
477 {
return std::get<_Ind>(
const_cast<const tuple<_Tp...
>&>(__tuple)); }
481#if __cplusplus == 201703L && _GLIBCXX_USE_DEPRECATED
482# define _GLIBCXX_VOLATILE_BIND
485# define _GLIBCXX_DEPR_BIND \
486 [[deprecated("std::bind does not support volatile in C++17")]]
487#elif __cplusplus < 201703L
488# define _GLIBCXX_VOLATILE_BIND
489# define _GLIBCXX_DEPR_BIND
493 template<
typename _Signature>
496 template<
typename _Functor,
typename... _Bound_args>
497 class _Bind<_Functor(_Bound_args...)>
498 :
public _Weak_result_type<_Functor>
500 typedef typename _Build_index_tuple<
sizeof...(_Bound_args)>::__type
504 tuple<_Bound_args...> _M_bound_args;
507 template<
typename _Result,
typename... _Args, std::size_t... _Indexes>
513 _Mu<_Bound_args>()(std::get<_Indexes>(_M_bound_args), __args)...
518 template<
typename _Result,
typename... _Args, std::size_t... _Indexes>
524 _Mu<_Bound_args>()(std::get<_Indexes>(_M_bound_args), __args)...
528#ifdef _GLIBCXX_VOLATILE_BIND
530 template<
typename _Result,
typename... _Args, std::size_t... _Indexes>
532 __call_v(tuple<_Args...>&& __args,
533 _Index_tuple<_Indexes...>)
volatile
536 _Mu<_Bound_args>()(__volget<_Indexes>(_M_bound_args), __args)...
541 template<
typename _Result,
typename... _Args, std::size_t... _Indexes>
543 __call_c_v(tuple<_Args...>&& __args,
544 _Index_tuple<_Indexes...>)
const volatile
547 _Mu<_Bound_args>()(__volget<_Indexes>(_M_bound_args), __args)...
552 template<
typename _BoundArg,
typename _CallArgs>
553 using _Mu_type =
decltype(
554 _Mu<typename remove_cv<_BoundArg>::type>()(
555 std::declval<_BoundArg&>(), std::declval<_CallArgs&>()) );
557 template<
typename _Fn,
typename _CallArgs,
typename... _BArgs>
559 =
typename result_of< _Fn&(_Mu_type<_BArgs, _CallArgs>&&...) >::type;
561 template<
typename _CallArgs>
562 using _Res_type = _Res_type_impl<_Functor, _CallArgs, _Bound_args...>;
564 template<
typename _CallArgs>
565 using __dependent =
typename
566 enable_if<bool(tuple_size<_CallArgs>::value+1), _Functor>::type;
568 template<
typename _CallArgs,
template<
class>
class __cv_quals>
569 using _Res_type_cv = _Res_type_impl<
570 typename __cv_quals<__dependent<_CallArgs>>::type,
572 typename __cv_quals<_Bound_args>::type...>;
575 template<
typename... _Args>
576 explicit _GLIBCXX20_CONSTEXPR
577 _Bind(
const _Functor& __f, _Args&&... __args)
578 : _M_f(__f), _M_bound_args(
std::
forward<_Args>(__args)...)
581 template<
typename... _Args>
582 explicit _GLIBCXX20_CONSTEXPR
583 _Bind(_Functor&& __f, _Args&&... __args)
587 _Bind(
const _Bind&) =
default;
588 _Bind(_Bind&&) =
default;
591 template<
typename... _Args,
592 typename _Result = _Res_type<tuple<_Args...>>>
595 operator()(_Args&&... __args)
597 return this->__call<_Result>(
603 template<
typename... _Args,
604 typename _Result = _Res_type_cv<tuple<_Args...>, add_const>>
607 operator()(_Args&&... __args)
const
609 return this->__call_c<_Result>(
614#ifdef _GLIBCXX_VOLATILE_BIND
616 template<
typename... _Args,
617 typename _Result = _Res_type_cv<tuple<_Args...>, add_volatile>>
620 operator()(_Args&&... __args)
volatile
622 return this->__call_v<_Result>(
628 template<
typename... _Args,
629 typename _Result = _Res_type_cv<tuple<_Args...>, add_cv>>
632 operator()(_Args&&... __args)
const volatile
634 return this->__call_c_v<_Result>(
642 template<
typename _Result,
typename _Signature>
645 template<
typename _Result,
typename _Functor,
typename... _Bound_args>
648 typedef typename _Build_index_tuple<
sizeof...(_Bound_args)>::__type
652 tuple<_Bound_args...> _M_bound_args;
655 template<
typename _Res,
typename... _Args, std::size_t... _Indexes>
660 return std::__invoke_r<_Res>(_M_f, _Mu<_Bound_args>()
661 (std::get<_Indexes>(_M_bound_args), __args)...);
665 template<
typename _Res,
typename... _Args, std::size_t... _Indexes>
670 return std::__invoke_r<_Res>(_M_f, _Mu<_Bound_args>()
671 (std::get<_Indexes>(_M_bound_args), __args)...);
674#ifdef _GLIBCXX_VOLATILE_BIND
676 template<
typename _Res,
typename... _Args, std::size_t... _Indexes>
680 return std::__invoke_r<_Res>(_M_f, _Mu<_Bound_args>()
681 (__volget<_Indexes>(_M_bound_args), __args)...);
685 template<
typename _Res,
typename... _Args, std::size_t... _Indexes>
688 _Index_tuple<_Indexes...>)
const volatile
690 return std::__invoke_r<_Res>(_M_f, _Mu<_Bound_args>()
691 (__volget<_Indexes>(_M_bound_args), __args)...);
696 typedef _Result result_type;
698 template<
typename... _Args>
699 explicit _GLIBCXX20_CONSTEXPR
701 : _M_f(__f), _M_bound_args(std::forward<_Args>(__args)...)
704 template<
typename... _Args>
705 explicit _GLIBCXX20_CONSTEXPR
707 : _M_f(
std::move(__f)), _M_bound_args(std::forward<_Args>(__args)...)
714 template<
typename... _Args>
717 operator()(_Args&&... __args)
719 return this->__call<_Result>(
725 template<
typename... _Args>
728 operator()(_Args&&... __args)
const
730 return this->__call<_Result>(
735#ifdef _GLIBCXX_VOLATILE_BIND
737 template<
typename... _Args>
740 operator()(_Args&&... __args)
volatile
742 return this->__call<_Result>(
748 template<
typename... _Args>
751 operator()(_Args&&... __args)
const volatile
753 return this->__call<_Result>(
758 template<
typename... _Args>
759 void operator()(_Args&&...)
const volatile =
delete;
763#undef _GLIBCXX_VOLATILE_BIND
764#undef _GLIBCXX_DEPR_BIND
770 template<
typename _Signature>
778 template<
typename _Signature>
786 template<
typename _Signature>
794 template<
typename _Signature>
802 template<
typename _Result,
typename _Signature>
810 template<
typename _Result,
typename _Signature>
818 template<
typename _Result,
typename _Signature>
826 template<
typename _Result,
typename _Signature>
830 template<
typename _Func,
typename... _BoundArgs>
831 struct _Bind_check_arity { };
833 template<
typename _Ret,
typename... _Args,
typename... _BoundArgs>
834 struct _Bind_check_arity<_Ret (*)(_Args...), _BoundArgs...>
836 static_assert(
sizeof...(_BoundArgs) ==
sizeof...(_Args),
837 "Wrong number of arguments for function");
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 _Tp,
typename _Class,
typename... _BoundArgs>
848 struct _Bind_check_arity<_Tp _Class::*, _BoundArgs...>
850 using _Arity =
typename _Mem_fn<_Tp _Class::*>::_Arity;
851 using _Varargs =
typename _Mem_fn<_Tp _Class::*>::_Varargs;
852 static_assert(_Varargs::value
853 ?
sizeof...(_BoundArgs) >= _Arity::value + 1
854 : sizeof...(_BoundArgs) == _Arity::value + 1,
855 "Wrong number of arguments for pointer-to-member");
861 template<typename _Tp, typename _Tp2 = typename decay<_Tp>::type>
862 using __is_socketlike = __or_<is_integral<_Tp2>, is_enum<_Tp2>>;
864 template<
bool _SocketLike,
typename _Func,
typename... _BoundArgs>
866 : _Bind_check_arity<typename decay<_Func>::type, _BoundArgs...>
868 typedef typename decay<_Func>::type __func_type;
869 typedef _Bind<__func_type(
typename decay<_BoundArgs>::type...)> type;
875 template<
typename _Func,
typename... _BoundArgs>
876 struct _Bind_helper<true, _Func, _BoundArgs...>
884 template<
typename _Func,
typename... _BoundArgs>
885 inline _GLIBCXX20_CONSTEXPR
typename
886 _Bind_helper<__is_socketlike<_Func>::value, _Func, _BoundArgs...>::type
887 bind(_Func&& __f, _BoundArgs&&... __args)
889 typedef _Bind_helper<
false, _Func, _BoundArgs...> __helper_type;
890 return typename __helper_type::type(std::forward<_Func>(__f),
891 std::forward<_BoundArgs>(__args)...);
894 template<
typename _Result,
typename _Func,
typename... _BoundArgs>
895 struct _Bindres_helper
896 : _Bind_check_arity<typename decay<_Func>::type, _BoundArgs...>
898 typedef typename decay<_Func>::type __functor_type;
899 typedef _Bind_result<_Result,
900 __functor_type(
typename decay<_BoundArgs>::type...)>
909 template<
typename _Result,
typename _Func,
typename... _BoundArgs>
910 inline _GLIBCXX20_CONSTEXPR
911 typename _Bindres_helper<_Result, _Func, _BoundArgs...>::type
912 bind(_Func&& __f, _BoundArgs&&... __args)
914 typedef _Bindres_helper<_Result, _Func, _BoundArgs...> __helper_type;
915 return typename __helper_type::type(std::forward<_Func>(__f),
916 std::forward<_BoundArgs>(__args)...);
919#ifdef __cpp_lib_bind_front
921 template<
typename _Fd,
typename... _BoundArgs>
924 static_assert(is_move_constructible_v<_Fd>);
925 static_assert((is_move_constructible_v<_BoundArgs> && ...));
929 template<
typename _Fn,
typename... _Args>
931 _Bind_front(
int, _Fn&& __fn, _Args&&... __args)
932 noexcept(__and_<is_nothrow_constructible<_Fd, _Fn>,
933 is_nothrow_constructible<_BoundArgs, _Args>...>::value)
934 : _M_fd(
std::forward<_Fn>(__fn)),
935 _M_bound_args(
std::forward<_Args>(__args)...)
936 {
static_assert(
sizeof...(_Args) ==
sizeof...(_BoundArgs)); }
938#if __cpp_explicit_this_parameter
939 template<
typename _Self,
typename... _CallArgs>
941 invoke_result_t<__like_t<_Self, _Fd>, __like_t<_Self, _BoundArgs>..., _CallArgs...>
942 operator()(
this _Self&& __self, _CallArgs&&... __call_args)
943 noexcept(is_nothrow_invocable_v<__like_t<_Self, _Fd>,
944 __like_t<_Self, _BoundArgs>..., _CallArgs...>)
946 return _S_call(std::forward<_Self>(__self), _BoundIndices(),
947 std::forward<_CallArgs>(__call_args)...);
950 template<
typename... _CallArgs>
953 invoke_result_t<_Fd&, _BoundArgs&..., _CallArgs...>
954 operator()(_CallArgs&&... __call_args) &
955 noexcept(is_nothrow_invocable_v<_Fd&, _BoundArgs&..., _CallArgs...>)
957 return _S_call(*
this, _BoundIndices(),
958 std::forward<_CallArgs>(__call_args)...);
961 template<
typename... _CallArgs>
964 invoke_result_t<
const _Fd&,
const _BoundArgs&..., _CallArgs...>
965 operator()(_CallArgs&&... __call_args)
const &
966 noexcept(is_nothrow_invocable_v<
const _Fd&,
const _BoundArgs&...,
969 return _S_call(*
this, _BoundIndices(),
970 std::forward<_CallArgs>(__call_args)...);
973 template<
typename... _CallArgs>
976 invoke_result_t<_Fd, _BoundArgs..., _CallArgs...>
977 operator()(_CallArgs&&... __call_args) &&
978 noexcept(is_nothrow_invocable_v<_Fd, _BoundArgs..., _CallArgs...>)
980 return _S_call(
std::move(*
this), _BoundIndices(),
981 std::forward<_CallArgs>(__call_args)...);
984 template<
typename... _CallArgs>
987 invoke_result_t<
const _Fd,
const _BoundArgs..., _CallArgs...>
988 operator()(_CallArgs&&... __call_args)
const &&
989 noexcept(is_nothrow_invocable_v<
const _Fd,
const _BoundArgs...,
992 return _S_call(
std::move(*
this), _BoundIndices(),
993 std::forward<_CallArgs>(__call_args)...);
996 template<
typename... _CallArgs>
997 void operator()(_CallArgs&&...) & =
delete;
999 template<
typename... _CallArgs>
1000 void operator()(_CallArgs&&...) const & = delete;
1002 template<typename... _CallArgs>
1003 void operator()(_CallArgs&&...) && = delete;
1005 template<typename... _CallArgs>
1006 void operator()(_CallArgs&&...) const && = delete;
1012 template<
typename _Tp,
size_t... _Ind,
typename... _CallArgs>
1015 _S_call(_Tp&& __g, index_sequence<_Ind...>, _CallArgs&&... __call_args)
1017 return std::invoke(std::forward<_Tp>(__g)._M_fd,
1018 std::get<_Ind>(std::forward<_Tp>(__g)._M_bound_args)...,
1019 std::forward<_CallArgs>(__call_args)...);
1022 [[no_unique_address]] _Fd _M_fd;
1023 [[no_unique_address]]
std::tuple<_BoundArgs...> _M_bound_args;
1026 template<
typename _Fn,
typename... _Args>
1027 using _Bind_front_t = _Bind_front<decay_t<_Fn>, decay_t<_Args>...>;
1038 template<
typename _Fn,
typename... _Args>
1039 constexpr _Bind_front_t<_Fn, _Args...>
1040 bind_front(_Fn&& __fn, _Args&&... __args)
1041 noexcept(is_nothrow_constructible_v<_Bind_front_t<_Fn, _Args...>,
1042 int, _Fn, _Args...>)
1044 return _Bind_front_t<_Fn, _Args...>(0, std::forward<_Fn>(__fn),
1045 std::forward<_Args>(__args)...);
1049#ifdef __cpp_lib_bind_back
1050 template<
typename _Fd,
typename... _BoundArgs>
1053 static_assert(is_move_constructible_v<_Fd>);
1054 static_assert((is_move_constructible_v<_BoundArgs> && ...));
1058 template<
typename _Fn,
typename... _Args>
1060 _Bind_back(
int, _Fn&& __fn, _Args&&... __args)
1061 noexcept(__and_<is_nothrow_constructible<_Fd, _Fn>,
1062 is_nothrow_constructible<_BoundArgs, _Args>...>::value)
1064 _M_bound_args(
std::
forward<_Args>(__args)...)
1065 {
static_assert(
sizeof...(_Args) ==
sizeof...(_BoundArgs)); }
1067 template<
typename _Self,
typename... _CallArgs>
1069 invoke_result_t<__like_t<_Self, _Fd>, _CallArgs..., __like_t<_Self, _BoundArgs>...>
1070 operator()(
this _Self&& __self, _CallArgs&&... __call_args)
1071 noexcept(is_nothrow_invocable_v<__like_t<_Self, _Fd>,
1072 _CallArgs..., __like_t<_Self, _BoundArgs>...>)
1074 return _S_call(std::forward<_Self>(__self), _BoundIndices(),
1075 std::forward<_CallArgs>(__call_args)...);
1081 template<
typename _Tp,
size_t... _Ind,
typename... _CallArgs>
1084 _S_call(_Tp&& __g, index_sequence<_Ind...>, _CallArgs&&... __call_args)
1086 return std::invoke(std::forward<_Tp>(__g)._M_fd,
1087 std::forward<_CallArgs>(__call_args)...,
1088 std::get<_Ind>(std::forward<_Tp>(__g)._M_bound_args)...);
1091 [[no_unique_address]] _Fd _M_fd;
1092 [[no_unique_address]]
std::tuple<_BoundArgs...> _M_bound_args;
1095 template<
typename _Fn,
typename... _Args>
1096 using _Bind_back_t = _Bind_back<decay_t<_Fn>, decay_t<_Args>...>;
1107 template<
typename _Fn,
typename... _Args>
1108 constexpr _Bind_back_t<_Fn, _Args...>
1109 bind_back(_Fn&& __fn, _Args&&... __args)
1110 noexcept(is_nothrow_constructible_v<_Bind_back_t<_Fn, _Args...>,
1111 int, _Fn, _Args...>)
1113 return _Bind_back_t<_Fn, _Args...>(0, std::forward<_Fn>(__fn),
1114 std::forward<_Args>(__args)...);
1118#if __cplusplus >= 201402L
1120 template<
typename _Fn>
1123 template<
typename _Fn2,
typename... _Args>
1124 using __inv_res_t =
typename __invoke_result<_Fn2, _Args...>::type;
1126 template<
typename _Tp>
1127 static decltype(!std::declval<_Tp>())
1128 _S_not()
noexcept(
noexcept(!std::declval<_Tp>()));
1131 template<
typename _Fn2>
1134 : _M_fn(std::forward<_Fn2>(__fn)) { }
1143#define _GLIBCXX_NOT_FN_CALL_OP( _QUALS ) \
1144 template<typename... _Args, \
1145 typename = enable_if_t<__is_invocable<_Fn _QUALS, _Args...>::value>> \
1146 _GLIBCXX20_CONSTEXPR \
1147 decltype(_S_not<__inv_res_t<_Fn _QUALS, _Args...>>()) \
1148 operator()(_Args&&... __args) _QUALS \
1149 noexcept(__is_nothrow_invocable<_Fn _QUALS, _Args...>::value \
1150 && noexcept(_S_not<__inv_res_t<_Fn _QUALS, _Args...>>())) \
1152 return !std::__invoke(std::forward< _Fn _QUALS >(_M_fn), \
1153 std::forward<_Args>(__args)...); \
1156 template<typename... _Args, \
1157 typename = enable_if_t<!__is_invocable<_Fn _QUALS, _Args...>::value>> \
1158 void operator()(_Args&&... __args) _QUALS = delete;
1160 _GLIBCXX_NOT_FN_CALL_OP( & )
1161 _GLIBCXX_NOT_FN_CALL_OP(
const & )
1162 _GLIBCXX_NOT_FN_CALL_OP( && )
1163 _GLIBCXX_NOT_FN_CALL_OP(
const && )
1164#undef _GLIBCXX_NOT_FN_CALL_OP
1170 template<
typename _Tp,
typename _Pred>
1173 template<
typename _Tp>
1174 struct __is_byte_like<_Tp, equal_to<_Tp>>
1175 : __bool_constant<sizeof(_Tp) == 1 && is_integral<_Tp>::value> { };
1177 template<
typename _Tp>
1178 struct __is_byte_like<_Tp, equal_to<void>>
1179 : __bool_constant<sizeof(_Tp) == 1 && is_integral<_Tp>::value> { };
1181#if __cplusplus >= 201703L
1183 enum class byte :
unsigned char;
1186 struct __is_byte_like<byte, equal_to<byte>>
1190 struct __is_byte_like<byte, equal_to<void>>
1195#ifdef __cpp_lib_not_fn
1208 template<
typename _Fn>
1209 _GLIBCXX20_CONSTEXPR
1214 return _Not_fn<std::decay_t<_Fn>>{std::forward<_Fn>(__fn), 0};
1218#if __cplusplus >= 201703L
1221 template<
typename _ForwardIterator1,
typename _BinaryPredicate = equal_to<>>
1222 class default_searcher
1225 _GLIBCXX20_CONSTEXPR
1226 default_searcher(_ForwardIterator1 __pat_first,
1227 _ForwardIterator1 __pat_last,
1228 _BinaryPredicate __pred = _BinaryPredicate())
1229 : _M_m(__pat_first, __pat_last,
std::
move(__pred))
1232 template<
typename _ForwardIterator2>
1233 _GLIBCXX20_CONSTEXPR
1234 pair<_ForwardIterator2, _ForwardIterator2>
1235 operator()(_ForwardIterator2 __first, _ForwardIterator2 __last)
const
1237 _ForwardIterator2 __first_ret =
1238 std::search(__first, __last, std::get<0>(_M_m), std::get<1>(_M_m),
1240 auto __ret = std::make_pair(__first_ret, __first_ret);
1241 if (__ret.first != __last)
1243 std::get<1>(_M_m)));
1248 tuple<_ForwardIterator1, _ForwardIterator1, _BinaryPredicate> _M_m;
1251#ifdef __cpp_lib_boyer_moore_searcher
1253 template<
typename _Key,
typename _Tp,
typename _Hash,
typename _Pred>
1254 struct __boyer_moore_map_base
1256 template<
typename _RAIter>
1257 __boyer_moore_map_base(_RAIter __pat,
size_t __patlen,
1258 _Hash&& __hf, _Pred&& __pred)
1262 for (__diff_type __i = 0; __i < __patlen - 1; ++__i)
1263 _M_bad_char[__pat[__i]] = __patlen - 1 - __i;
1266 using __diff_type = _Tp;
1269 _M_lookup(_Key __key, __diff_type __not_found)
const
1271 auto __iter = _M_bad_char.find(__key);
1272 if (__iter == _M_bad_char.end())
1274 return __iter->second;
1278 _M_pred()
const {
return _M_bad_char.key_eq(); }
1280 _GLIBCXX_STD_C::unordered_map<_Key, _Tp, _Hash, _Pred> _M_bad_char;
1283 template<
typename _Tp,
size_t _Len,
typename _Pred>
1284 struct __boyer_moore_array_base
1286 template<
typename _RAIter,
typename _Unused>
1287 __boyer_moore_array_base(_RAIter __pat,
size_t __patlen,
1288 _Unused&&, _Pred&& __pred)
1289 : _M_bad_char{ array<_Tp, _Len>{},
std::move(__pred) }
1291 std::get<0>(_M_bad_char).fill(__patlen);
1293 for (__diff_type __i = 0; __i < __patlen - 1; ++__i)
1295 auto __ch = __pat[__i];
1297 auto __uch =
static_cast<_UCh
>(__ch);
1298 std::get<0>(_M_bad_char)[__uch] = __patlen - 1 - __i;
1302 using __diff_type = _Tp;
1304 template<
typename _Key>
1306 _M_lookup(_Key __key, __diff_type __not_found)
const
1308 auto __ukey =
static_cast<make_unsigned_t<_Key>
>(__key);
1311 return std::get<0>(_M_bad_char)[__ukey];
1315 _M_pred()
const {
return std::get<1>(_M_bad_char); }
1317 tuple<array<_Tp, _Len>, _Pred> _M_bad_char;
1322 template<
typename _RAIter,
typename _Hash,
typename _Pred,
1323 typename _Val =
typename iterator_traits<_RAIter>::value_type,
1324 typename _Diff =
typename iterator_traits<_RAIter>::difference_type>
1325 using __boyer_moore_base_t
1326 = __conditional_t<__is_byte_like<_Val, _Pred>::value,
1327 __boyer_moore_array_base<_Diff, 256, _Pred>,
1328 __boyer_moore_map_base<_Val, _Diff, _Hash, _Pred>>;
1330 template<
typename _RAIter,
typename _Hash
1331 = hash<typename iterator_traits<_RAIter>::value_type>,
1332 typename _BinaryPredicate = equal_to<>>
1333 class boyer_moore_searcher
1334 : __boyer_moore_base_t<_RAIter, _Hash, _BinaryPredicate>
1336 using _Base = __boyer_moore_base_t<_RAIter, _Hash, _BinaryPredicate>;
1337 using typename _Base::__diff_type;
1340 boyer_moore_searcher(_RAIter __pat_first, _RAIter __pat_last,
1341 _Hash __hf = _Hash(),
1342 _BinaryPredicate __pred = _BinaryPredicate());
1344 template<
typename _RandomAccessIterator2>
1345 pair<_RandomAccessIterator2, _RandomAccessIterator2>
1346 operator()(_RandomAccessIterator2 __first,
1347 _RandomAccessIterator2 __last)
const;
1351 _M_is_prefix(_RAIter __word, __diff_type __len,
1354 const auto& __pred = this->_M_pred();
1355 __diff_type __suffixlen = __len - __pos;
1356 for (__diff_type __i = 0; __i < __suffixlen; ++__i)
1357 if (!__pred(__word[__i], __word[__pos + __i]))
1363 _M_suffix_length(_RAIter __word, __diff_type __len,
1366 const auto& __pred = this->_M_pred();
1367 __diff_type __i = 0;
1368 while (__pred(__word[__pos - __i], __word[__len - 1 - __i])
1376 template<
typename _Tp>
1378 _M_bad_char_shift(_Tp __c)
const
1379 {
return this->_M_lookup(__c, _M_pat_end - _M_pat); }
1383 _GLIBCXX_STD_C::vector<__diff_type> _M_good_suffix;
1386 template<
typename _RAIter,
typename _Hash
1387 = hash<typename iterator_traits<_RAIter>::value_type>,
1388 typename _BinaryPredicate = equal_to<>>
1389 class boyer_moore_horspool_searcher
1390 : __boyer_moore_base_t<_RAIter, _Hash, _BinaryPredicate>
1392 using _Base = __boyer_moore_base_t<_RAIter, _Hash, _BinaryPredicate>;
1393 using typename _Base::__diff_type;
1396 boyer_moore_horspool_searcher(_RAIter __pat,
1398 _Hash __hf = _Hash(),
1399 _BinaryPredicate __pred
1400 = _BinaryPredicate())
1401 : _Base(__pat, __pat_end - __pat,
std::
move(__hf),
std::
move(__pred)),
1402 _M_pat(__pat), _M_pat_end(__pat_end)
1405 template<
typename _RandomAccessIterator2>
1406 pair<_RandomAccessIterator2, _RandomAccessIterator2>
1407 operator()(_RandomAccessIterator2 __first,
1408 _RandomAccessIterator2 __last)
const
1410 const auto& __pred = this->_M_pred();
1411 auto __patlen = _M_pat_end - _M_pat;
1413 return std::make_pair(__first, __first);
1414 auto __len = __last - __first;
1415 while (__len >= __patlen)
1417 for (
auto __scan = __patlen - 1;
1418 __pred(__first[__scan], _M_pat[__scan]); --__scan)
1420 return std::make_pair(__first, __first + __patlen);
1421 auto __shift = _M_bad_char_shift(__first[__patlen - 1]);
1425 return std::make_pair(__last, __last);
1429 template<
typename _Tp>
1431 _M_bad_char_shift(_Tp __c)
const
1432 {
return this->_M_lookup(__c, _M_pat_end - _M_pat); }
1438 template<
typename _RAIter,
typename _Hash,
typename _BinaryPredicate>
1439 boyer_moore_searcher<_RAIter, _Hash, _BinaryPredicate>::
1440 boyer_moore_searcher(_RAIter __pat, _RAIter __pat_end,
1441 _Hash __hf, _BinaryPredicate __pred)
1442 : _Base(__pat, __pat_end - __pat,
std::
move(__hf),
std::
move(__pred)),
1443 _M_pat(__pat), _M_pat_end(__pat_end), _M_good_suffix(__pat_end - __pat)
1445 auto __patlen = __pat_end - __pat;
1448 __diff_type __last_prefix = __patlen - 1;
1449 for (__diff_type __p = __patlen - 1; __p >= 0; --__p)
1451 if (_M_is_prefix(__pat, __patlen, __p + 1))
1452 __last_prefix = __p + 1;
1453 _M_good_suffix[__p] = __last_prefix + (__patlen - 1 - __p);
1455 for (__diff_type __p = 0; __p < __patlen - 1; ++__p)
1457 auto __slen = _M_suffix_length(__pat, __patlen, __p);
1458 auto __pos = __patlen - 1 - __slen;
1459 if (!__pred(__pat[__p - __slen], __pat[__pos]))
1460 _M_good_suffix[__pos] = __patlen - 1 - __p + __slen;
1464 template<
typename _RAIter,
typename _Hash,
typename _BinaryPredicate>
1465 template<
typename _RandomAccessIterator2>
1466 pair<_RandomAccessIterator2, _RandomAccessIterator2>
1467 boyer_moore_searcher<_RAIter, _Hash, _BinaryPredicate>::
1468 operator()(_RandomAccessIterator2 __first,
1469 _RandomAccessIterator2 __last)
const
1471 auto __patlen = _M_pat_end - _M_pat;
1473 return std::make_pair(__first, __first);
1474 const auto& __pred = this->_M_pred();
1475 __diff_type __i = __patlen - 1;
1476 auto __stringlen = __last - __first;
1477 while (__i < __stringlen)
1479 __diff_type __j = __patlen - 1;
1480 while (__j >= 0 && __pred(__first[__i], _M_pat[__j]))
1487 const auto __match = __first + __i + 1;
1488 return std::make_pair(__match, __match + __patlen);
1490 __i +=
std::max(_M_bad_char_shift(__first[__i]),
1491 _M_good_suffix[__j]);
1493 return std::make_pair(__last, __last);
1501_GLIBCXX_END_NAMESPACE_VERSION
typename make_unsigned< _Tp >::type make_unsigned_t
Alias template for make_unsigned.
__bool_constant< true > true_type
The type used as a compile-time boolean with true value.
__bool_constant< false > false_type
The type used as a compile-time boolean with false value.
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.
make_index_sequence< sizeof...(_Types)> index_sequence_for
Alias template index_sequence_for.
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.