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_reference_wrapper
87#define __glibcxx_want_transparent_operators
92namespace std _GLIBCXX_VISIBILITY(default)
94_GLIBCXX_BEGIN_NAMESPACE_VERSION
102#ifdef __cpp_lib_invoke
115 template<
typename _Callable,
typename... _Args>
116 inline _GLIBCXX20_CONSTEXPR invoke_result_t<_Callable, _Args...>
117 invoke(_Callable&& __fn, _Args&&... __args)
118 noexcept(is_nothrow_invocable_v<_Callable, _Args...>)
121 std::forward<_Args>(__args)...);
125#ifdef __cpp_lib_invoke_r
134 template<
typename _Res,
typename _Callable,
typename... _Args>
135 requires is_invocable_r_v<_Res, _Callable, _Args...>
137 invoke_r(_Callable&& __fn, _Args&&... __args)
138 noexcept(is_nothrow_invocable_r_v<_Res, _Callable, _Args...>)
140 return std::__invoke_r<_Res>(std::forward<_Callable>(__fn),
141 std::forward<_Args>(__args)...);
147#if __cplusplus >= 201103L
148 template<
typename _MemFunPtr,
149 bool __is_mem_fn = is_member_function_pointer<_MemFunPtr>::value>
151 :
public _Mem_fn_traits<_MemFunPtr>::__maybe_type
153 using _Traits = _Mem_fn_traits<_MemFunPtr>;
155 using _Arity =
typename _Traits::__arity;
156 using _Varargs =
typename _Traits::__vararg;
158 template<
typename _Func,
typename... _BoundArgs>
159 friend struct _Bind_check_arity;
165 using result_type =
typename _Traits::__result_type;
168 _Mem_fn_base(_MemFunPtr __pmf) noexcept : _M_pmf(__pmf) { }
170 template<
typename... _Args>
173 operator()(_Args&&... __args)
const
176 ->
decltype(
std::__invoke(_M_pmf, std::forward<_Args>(__args)...))
177 {
return std::__invoke(_M_pmf, std::forward<_Args>(__args)...); }
181 template<
typename _MemObjPtr>
182 class _Mem_fn_base<_MemObjPtr, false>
184 using _Arity = integral_constant<size_t, 0>;
187 template<
typename _Func,
typename... _BoundArgs>
188 friend struct _Bind_check_arity;
194 _Mem_fn_base(_MemObjPtr __pm) noexcept : _M_pm(__pm) { }
196 template<
typename _Tp>
199 operator()(_Tp&& __obj)
const
200 noexcept(
noexcept(
std::__invoke(_M_pm, std::forward<_Tp>(__obj))))
205 template<
typename _MemberPo
inter>
208 template<
typename _Res,
typename _Class>
209 struct _Mem_fn<_Res _Class::*>
210 : _Mem_fn_base<_Res _Class::*>
212 using _Mem_fn_base<_Res _Class::*>::_Mem_fn_base;
241 template<
typename _Tp,
typename _Class>
243 inline _Mem_fn<_Tp _Class::*>
246 return _Mem_fn<_Tp _Class::*>(__pm);
260 template<
typename _Tp>
272 template<
typename _Tp>
277#if __cplusplus > 201402L
278 template <
typename _Tp>
inline constexpr bool is_bind_expression_v
280 template <
typename _Tp>
inline constexpr int is_placeholder_v
289 namespace placeholders
295#if __cpp_inline_variables
296# define _GLIBCXX_PLACEHOLDER inline
298# define _GLIBCXX_PLACEHOLDER extern
331#undef _GLIBCXX_PLACEHOLDER
353 template<std::
size_t __i,
typename _Tuple>
354 using _Safe_tuple_element_t
355 =
typename enable_if<(__i < tuple_size<_Tuple>::value),
356 tuple_element<__i, _Tuple>>::type::type;
369 template<
typename _Arg,
370 bool _IsBindExp = is_bind_expression<_Arg>::value,
371 bool _IsPlaceholder = (is_placeholder<_Arg>::value > 0)>
379 template<
typename _Tp>
380 class _Mu<reference_wrapper<_Tp>, false, false>
387 template<
typename _CVRef,
typename _Tuple>
390 operator()(_CVRef& __arg, _Tuple&)
const volatile
391 {
return __arg.get(); }
400 template<
typename _Arg>
401 class _Mu<_Arg, true, false>
404 template<
typename _CVArg,
typename... _Args>
407 operator()(_CVArg& __arg,
408 tuple<_Args...>& __tuple)
const volatile
409 ->
decltype(__arg(declval<_Args>()...))
412 typedef typename _Build_index_tuple<
sizeof...(_Args)>::__type
414 return this->__call(__arg, __tuple, _Indexes());
420 template<
typename _CVArg,
typename... _Args, std::size_t... _Indexes>
423 __call(_CVArg& __arg, tuple<_Args...>& __tuple,
424 const _Index_tuple<_Indexes...>&)
const volatile
425 ->
decltype(__arg(declval<_Args>()...))
427 return __arg(std::get<_Indexes>(
std::move(__tuple))...);
436 template<
typename _Arg>
437 class _Mu<_Arg, false, true>
440 template<
typename _Tuple>
442 _Safe_tuple_element_t<(is_placeholder<_Arg>::value - 1), _Tuple>&&
443 operator()(
const volatile _Arg&, _Tuple& __tuple)
const volatile
446 ::std::get<(is_placeholder<_Arg>::value - 1)>(
std::move(__tuple));
455 template<
typename _Arg>
456 class _Mu<_Arg, false, false>
459 template<
typename _CVArg,
typename _Tuple>
462 operator()(_CVArg&& __arg, _Tuple&)
const volatile
463 {
return std::forward<_CVArg>(__arg); }
467 template<std::size_t _Ind,
typename... _Tp>
469 __volget(
volatile tuple<_Tp...>& __tuple)
470 -> __tuple_element_t<_Ind, tuple<_Tp...>>
volatile&
471 {
return std::get<_Ind>(
const_cast<tuple<_Tp...
>&>(__tuple)); }
474 template<std::size_t _Ind,
typename... _Tp>
476 __volget(
const volatile tuple<_Tp...>& __tuple)
477 -> __tuple_element_t<_Ind, tuple<_Tp...>>
const volatile&
478 {
return std::get<_Ind>(
const_cast<const tuple<_Tp...
>&>(__tuple)); }
482#if __cplusplus == 201703L && _GLIBCXX_USE_DEPRECATED
483# define _GLIBCXX_VOLATILE_BIND
486# define _GLIBCXX_DEPR_BIND \
487 [[deprecated("std::bind does not support volatile in C++17")]]
488#elif __cplusplus < 201703L
489# define _GLIBCXX_VOLATILE_BIND
490# define _GLIBCXX_DEPR_BIND
494 template<
typename _Signature>
497 template<
typename _Functor,
typename... _Bound_args>
498 class _Bind<_Functor(_Bound_args...)>
499 :
public _Weak_result_type<_Functor>
501 typedef typename _Build_index_tuple<
sizeof...(_Bound_args)>::__type
505 tuple<_Bound_args...> _M_bound_args;
508 template<
typename _Result,
typename... _Args, std::size_t... _Indexes>
514 _Mu<_Bound_args>()(std::get<_Indexes>(_M_bound_args), __args)...
519 template<
typename _Result,
typename... _Args, std::size_t... _Indexes>
525 _Mu<_Bound_args>()(std::get<_Indexes>(_M_bound_args), __args)...
529#ifdef _GLIBCXX_VOLATILE_BIND
531 template<
typename _Result,
typename... _Args, std::size_t... _Indexes>
533 __call_v(tuple<_Args...>&& __args,
534 _Index_tuple<_Indexes...>)
volatile
537 _Mu<_Bound_args>()(__volget<_Indexes>(_M_bound_args), __args)...
542 template<
typename _Result,
typename... _Args, std::size_t... _Indexes>
544 __call_c_v(tuple<_Args...>&& __args,
545 _Index_tuple<_Indexes...>)
const volatile
548 _Mu<_Bound_args>()(__volget<_Indexes>(_M_bound_args), __args)...
553 template<
typename _BoundArg,
typename _CallArgs>
554 using _Mu_type =
decltype(
555 _Mu<typename remove_cv<_BoundArg>::type>()(
556 std::declval<_BoundArg&>(), std::declval<_CallArgs&>()) );
558 template<
typename _Fn,
typename _CallArgs,
typename... _BArgs>
560 = __invoke_result_t<_Fn&, _Mu_type<_BArgs, _CallArgs>&&...>;
562 template<
typename _CallArgs>
563 using _Res_type = _Res_type_impl<_Functor, _CallArgs, _Bound_args...>;
565 template<
typename _CallArgs>
566 using __dependent =
typename
567 enable_if<bool(tuple_size<_CallArgs>::value+1), _Functor>::type;
569 template<
typename _CallArgs,
template<
class>
class __cv_quals>
570 using _Res_type_cv = _Res_type_impl<
571 typename __cv_quals<__dependent<_CallArgs>>::type,
573 typename __cv_quals<_Bound_args>::type...>;
576 template<
typename... _Args>
577 explicit _GLIBCXX20_CONSTEXPR
578 _Bind(
const _Functor& __f, _Args&&... __args)
579 : _M_f(__f), _M_bound_args(
std::
forward<_Args>(__args)...)
582 template<
typename... _Args>
583 explicit _GLIBCXX20_CONSTEXPR
584 _Bind(_Functor&& __f, _Args&&... __args)
588 _Bind(
const _Bind&) =
default;
589 _Bind(_Bind&&) =
default;
592 template<
typename... _Args,
593 typename _Result = _Res_type<tuple<_Args...>>>
596 operator()(_Args&&... __args)
598 return this->__call<_Result>(
604 template<
typename... _Args,
605 typename _Result = _Res_type_cv<tuple<_Args...>, add_const>>
608 operator()(_Args&&... __args)
const
610 return this->__call_c<_Result>(
615#ifdef _GLIBCXX_VOLATILE_BIND
617 template<
typename... _Args,
618 typename _Result = _Res_type_cv<tuple<_Args...>, add_volatile>>
621 operator()(_Args&&... __args)
volatile
623 return this->__call_v<_Result>(
629 template<
typename... _Args,
630 typename _Result = _Res_type_cv<tuple<_Args...>, add_cv>>
633 operator()(_Args&&... __args)
const volatile
635 return this->__call_c_v<_Result>(
643 template<
typename _Result,
typename _Signature>
646 template<
typename _Result,
typename _Functor,
typename... _Bound_args>
649 typedef typename _Build_index_tuple<
sizeof...(_Bound_args)>::__type
653 tuple<_Bound_args...> _M_bound_args;
656 template<
typename _Res,
typename... _Args, std::size_t... _Indexes>
661 return std::__invoke_r<_Res>(_M_f, _Mu<_Bound_args>()
662 (std::get<_Indexes>(_M_bound_args), __args)...);
666 template<
typename _Res,
typename... _Args, std::size_t... _Indexes>
671 return std::__invoke_r<_Res>(_M_f, _Mu<_Bound_args>()
672 (std::get<_Indexes>(_M_bound_args), __args)...);
675#ifdef _GLIBCXX_VOLATILE_BIND
677 template<
typename _Res,
typename... _Args, std::size_t... _Indexes>
681 return std::__invoke_r<_Res>(_M_f, _Mu<_Bound_args>()
682 (__volget<_Indexes>(_M_bound_args), __args)...);
686 template<
typename _Res,
typename... _Args, std::size_t... _Indexes>
689 _Index_tuple<_Indexes...>)
const volatile
691 return std::__invoke_r<_Res>(_M_f, _Mu<_Bound_args>()
692 (__volget<_Indexes>(_M_bound_args), __args)...);
697 typedef _Result result_type;
699 template<
typename... _Args>
700 explicit _GLIBCXX20_CONSTEXPR
702 : _M_f(__f), _M_bound_args(std::forward<_Args>(__args)...)
705 template<
typename... _Args>
706 explicit _GLIBCXX20_CONSTEXPR
708 : _M_f(
std::move(__f)), _M_bound_args(std::forward<_Args>(__args)...)
715 template<
typename... _Args>
718 operator()(_Args&&... __args)
720 return this->__call<_Result>(
726 template<
typename... _Args>
729 operator()(_Args&&... __args)
const
731 return this->__call<_Result>(
736#ifdef _GLIBCXX_VOLATILE_BIND
738 template<
typename... _Args>
741 operator()(_Args&&... __args)
volatile
743 return this->__call<_Result>(
749 template<
typename... _Args>
752 operator()(_Args&&... __args)
const volatile
754 return this->__call<_Result>(
759 template<
typename... _Args>
760 void operator()(_Args&&...)
const volatile =
delete;
764#undef _GLIBCXX_VOLATILE_BIND
765#undef _GLIBCXX_DEPR_BIND
771 template<
typename _Signature>
779 template<
typename _Signature>
787 template<
typename _Signature>
795 template<
typename _Signature>
803 template<
typename _Result,
typename _Signature>
811 template<
typename _Result,
typename _Signature>
819 template<
typename _Result,
typename _Signature>
827 template<
typename _Result,
typename _Signature>
831 template<
typename _Func,
typename... _BoundArgs>
832 struct _Bind_check_arity { };
834 template<
typename _Ret,
typename... _Args,
typename... _BoundArgs>
835 struct _Bind_check_arity<_Ret (*)(_Args...), _BoundArgs...>
837 static_assert(
sizeof...(_BoundArgs) ==
sizeof...(_Args),
838 "Wrong number of arguments for function");
841 template<
typename _Ret,
typename... _Args,
typename... _BoundArgs>
842 struct _Bind_check_arity<_Ret (*)(_Args......), _BoundArgs...>
844 static_assert(
sizeof...(_BoundArgs) >=
sizeof...(_Args),
845 "Wrong number of arguments for function");
848 template<
typename _Tp,
typename _Class,
typename... _BoundArgs>
849 struct _Bind_check_arity<_Tp _Class::*, _BoundArgs...>
851 using _Arity =
typename _Mem_fn<_Tp _Class::*>::_Arity;
852 using _Varargs =
typename _Mem_fn<_Tp _Class::*>::_Varargs;
853 static_assert(_Varargs::value
854 ?
sizeof...(_BoundArgs) >= _Arity::value + 1
855 : sizeof...(_BoundArgs) == _Arity::value + 1,
856 "Wrong number of arguments for pointer-to-member");
862 template<typename _Tp, typename _Tp2 = typename decay<_Tp>::type>
863 using __is_socketlike = __or_<is_integral<_Tp2>, is_enum<_Tp2>>;
865 template<
bool _SocketLike,
typename _Func,
typename... _BoundArgs>
867 : _Bind_check_arity<typename decay<_Func>::type, _BoundArgs...>
869 typedef typename decay<_Func>::type __func_type;
870 typedef _Bind<__func_type(
typename decay<_BoundArgs>::type...)> type;
876 template<
typename _Func,
typename... _BoundArgs>
877 struct _Bind_helper<true, _Func, _BoundArgs...>
885 template<
typename _Func,
typename... _BoundArgs>
886 inline _GLIBCXX20_CONSTEXPR
typename
887 _Bind_helper<__is_socketlike<_Func>::value, _Func, _BoundArgs...>::type
888 bind(_Func&& __f, _BoundArgs&&... __args)
890 typedef _Bind_helper<
false, _Func, _BoundArgs...> __helper_type;
891 return typename __helper_type::type(std::forward<_Func>(__f),
892 std::forward<_BoundArgs>(__args)...);
895 template<
typename _Result,
typename _Func,
typename... _BoundArgs>
896 struct _Bindres_helper
897 : _Bind_check_arity<typename decay<_Func>::type, _BoundArgs...>
899 typedef typename decay<_Func>::type __functor_type;
900 typedef _Bind_result<_Result,
901 __functor_type(
typename decay<_BoundArgs>::type...)>
910 template<
typename _Result,
typename _Func,
typename... _BoundArgs>
911 inline _GLIBCXX20_CONSTEXPR
912 typename _Bindres_helper<_Result, _Func, _BoundArgs...>::type
913 bind(_Func&& __f, _BoundArgs&&... __args)
915 typedef _Bindres_helper<_Result, _Func, _BoundArgs...> __helper_type;
916 return typename __helper_type::type(std::forward<_Func>(__f),
917 std::forward<_BoundArgs>(__args)...);
920#ifdef __cpp_lib_bind_front
922 template<
typename _Fd,
typename... _BoundArgs>
925 static_assert(is_move_constructible_v<_Fd>);
926 static_assert((is_move_constructible_v<_BoundArgs> && ...));
930 template<
typename _Fn,
typename... _Args>
932 _Bind_front(
int, _Fn&& __fn, _Args&&... __args)
933 noexcept(__and_<is_nothrow_constructible<_Fd, _Fn>,
934 is_nothrow_constructible<_BoundArgs, _Args>...>::value)
935 : _M_fd(
std::forward<_Fn>(__fn)),
936 _M_bound_args(
std::forward<_Args>(__args)...)
937 {
static_assert(
sizeof...(_Args) ==
sizeof...(_BoundArgs)); }
939#if __cpp_explicit_this_parameter
940 template<
typename _Self,
typename... _CallArgs>
942 invoke_result_t<__like_t<_Self, _Fd>, __like_t<_Self, _BoundArgs>..., _CallArgs...>
943 operator()(
this _Self&& __self, _CallArgs&&... __call_args)
944 noexcept(is_nothrow_invocable_v<__like_t<_Self, _Fd>,
945 __like_t<_Self, _BoundArgs>..., _CallArgs...>)
947 return _S_call(std::forward<_Self>(__self), _BoundIndices(),
948 std::forward<_CallArgs>(__call_args)...);
951 template<
typename... _CallArgs>
954 invoke_result_t<_Fd&, _BoundArgs&..., _CallArgs...>
955 operator()(_CallArgs&&... __call_args) &
956 noexcept(is_nothrow_invocable_v<_Fd&, _BoundArgs&..., _CallArgs...>)
958 return _S_call(*
this, _BoundIndices(),
959 std::forward<_CallArgs>(__call_args)...);
962 template<
typename... _CallArgs>
965 invoke_result_t<
const _Fd&,
const _BoundArgs&..., _CallArgs...>
966 operator()(_CallArgs&&... __call_args)
const &
967 noexcept(is_nothrow_invocable_v<
const _Fd&,
const _BoundArgs&...,
970 return _S_call(*
this, _BoundIndices(),
971 std::forward<_CallArgs>(__call_args)...);
974 template<
typename... _CallArgs>
977 invoke_result_t<_Fd, _BoundArgs..., _CallArgs...>
978 operator()(_CallArgs&&... __call_args) &&
979 noexcept(is_nothrow_invocable_v<_Fd, _BoundArgs..., _CallArgs...>)
981 return _S_call(
std::move(*
this), _BoundIndices(),
982 std::forward<_CallArgs>(__call_args)...);
985 template<
typename... _CallArgs>
988 invoke_result_t<
const _Fd,
const _BoundArgs..., _CallArgs...>
989 operator()(_CallArgs&&... __call_args)
const &&
990 noexcept(is_nothrow_invocable_v<
const _Fd,
const _BoundArgs...,
993 return _S_call(
std::move(*
this), _BoundIndices(),
994 std::forward<_CallArgs>(__call_args)...);
997 template<
typename... _CallArgs>
998 void operator()(_CallArgs&&...) & =
delete;
1000 template<
typename... _CallArgs>
1001 void operator()(_CallArgs&&...) const & = delete;
1003 template<typename... _CallArgs>
1004 void operator()(_CallArgs&&...) && = delete;
1006 template<typename... _CallArgs>
1007 void operator()(_CallArgs&&...) const && = delete;
1013 template<
typename _Tp,
size_t... _Ind,
typename... _CallArgs>
1016 _S_call(_Tp&& __g, index_sequence<_Ind...>, _CallArgs&&... __call_args)
1018 return std::invoke(std::forward<_Tp>(__g)._M_fd,
1019 std::get<_Ind>(std::forward<_Tp>(__g)._M_bound_args)...,
1020 std::forward<_CallArgs>(__call_args)...);
1023 [[no_unique_address]] _Fd _M_fd;
1024 [[no_unique_address]]
std::tuple<_BoundArgs...> _M_bound_args;
1027 template<
typename _Fn,
typename... _Args>
1028 using _Bind_front_t = _Bind_front<decay_t<_Fn>, decay_t<_Args>...>;
1039 template<
typename _Fn,
typename... _Args>
1040 constexpr _Bind_front_t<_Fn, _Args...>
1041 bind_front(_Fn&& __fn, _Args&&... __args)
1042 noexcept(is_nothrow_constructible_v<_Bind_front_t<_Fn, _Args...>,
1043 int, _Fn, _Args...>)
1045 return _Bind_front_t<_Fn, _Args...>(0, std::forward<_Fn>(__fn),
1046 std::forward<_Args>(__args)...);
1050#ifdef __cpp_lib_bind_back
1051 template<
typename _Fd,
typename... _BoundArgs>
1054 static_assert(is_move_constructible_v<_Fd>);
1055 static_assert((is_move_constructible_v<_BoundArgs> && ...));
1059 template<
typename _Fn,
typename... _Args>
1061 _Bind_back(
int, _Fn&& __fn, _Args&&... __args)
1062 noexcept(__and_<is_nothrow_constructible<_Fd, _Fn>,
1063 is_nothrow_constructible<_BoundArgs, _Args>...>::value)
1065 _M_bound_args(
std::
forward<_Args>(__args)...)
1066 {
static_assert(
sizeof...(_Args) ==
sizeof...(_BoundArgs)); }
1068 template<
typename _Self,
typename... _CallArgs>
1070 invoke_result_t<__like_t<_Self, _Fd>, _CallArgs..., __like_t<_Self, _BoundArgs>...>
1071 operator()(
this _Self&& __self, _CallArgs&&... __call_args)
1072 noexcept(is_nothrow_invocable_v<__like_t<_Self, _Fd>,
1073 _CallArgs..., __like_t<_Self, _BoundArgs>...>)
1075 return _S_call(std::forward<_Self>(__self), _BoundIndices(),
1076 std::forward<_CallArgs>(__call_args)...);
1082 template<
typename _Tp,
size_t... _Ind,
typename... _CallArgs>
1085 _S_call(_Tp&& __g, index_sequence<_Ind...>, _CallArgs&&... __call_args)
1087 return std::invoke(std::forward<_Tp>(__g)._M_fd,
1088 std::forward<_CallArgs>(__call_args)...,
1089 std::get<_Ind>(std::forward<_Tp>(__g)._M_bound_args)...);
1092 [[no_unique_address]] _Fd _M_fd;
1093 [[no_unique_address]]
std::tuple<_BoundArgs...> _M_bound_args;
1096 template<
typename _Fn,
typename... _Args>
1097 using _Bind_back_t = _Bind_back<decay_t<_Fn>, decay_t<_Args>...>;
1108 template<
typename _Fn,
typename... _Args>
1109 constexpr _Bind_back_t<_Fn, _Args...>
1110 bind_back(_Fn&& __fn, _Args&&... __args)
1111 noexcept(is_nothrow_constructible_v<_Bind_back_t<_Fn, _Args...>,
1112 int, _Fn, _Args...>)
1114 return _Bind_back_t<_Fn, _Args...>(0, std::forward<_Fn>(__fn),
1115 std::forward<_Args>(__args)...);
1119#if __cplusplus >= 201402L
1121 template<
typename _Fn>
1124 template<
typename _Fn2,
typename... _Args>
1125 using __inv_res_t =
typename __invoke_result<_Fn2, _Args...>::type;
1127 template<
typename _Tp>
1128 static decltype(!std::declval<_Tp>())
1129 _S_not()
noexcept(
noexcept(!std::declval<_Tp>()));
1132 template<
typename _Fn2>
1135 : _M_fn(std::forward<_Fn2>(__fn)) { }
1144#define _GLIBCXX_NOT_FN_CALL_OP( _QUALS ) \
1145 template<typename... _Args, \
1146 typename = enable_if_t<__is_invocable<_Fn _QUALS, _Args...>::value>> \
1147 _GLIBCXX20_CONSTEXPR \
1148 decltype(_S_not<__inv_res_t<_Fn _QUALS, _Args...>>()) \
1149 operator()(_Args&&... __args) _QUALS \
1150 noexcept(__is_nothrow_invocable<_Fn _QUALS, _Args...>::value \
1151 && noexcept(_S_not<__inv_res_t<_Fn _QUALS, _Args...>>())) \
1153 return !std::__invoke(std::forward< _Fn _QUALS >(_M_fn), \
1154 std::forward<_Args>(__args)...); \
1157 template<typename... _Args, \
1158 typename = enable_if_t<!__is_invocable<_Fn _QUALS, _Args...>::value>> \
1159 void operator()(_Args&&... __args) _QUALS = delete;
1161 _GLIBCXX_NOT_FN_CALL_OP( & )
1162 _GLIBCXX_NOT_FN_CALL_OP(
const & )
1163 _GLIBCXX_NOT_FN_CALL_OP( && )
1164 _GLIBCXX_NOT_FN_CALL_OP(
const && )
1165#undef _GLIBCXX_NOT_FN_CALL_OP
1171 template<
typename _Tp,
typename _Pred>
1174 template<
typename _Tp>
1175 struct __is_byte_like<_Tp, equal_to<_Tp>>
1176 : __bool_constant<sizeof(_Tp) == 1 && is_integral<_Tp>::value> { };
1178 template<
typename _Tp>
1179 struct __is_byte_like<_Tp, equal_to<void>>
1180 : __bool_constant<sizeof(_Tp) == 1 && is_integral<_Tp>::value> { };
1182#if __cplusplus >= 201703L
1184 enum class byte :
unsigned char;
1187 struct __is_byte_like<byte, equal_to<byte>>
1191 struct __is_byte_like<byte, equal_to<void>>
1196#ifdef __cpp_lib_not_fn
1209 template<
typename _Fn>
1210 _GLIBCXX20_CONSTEXPR
1215 return _Not_fn<std::decay_t<_Fn>>{std::forward<_Fn>(__fn), 0};
1219#if __cplusplus >= 201703L
1222 template<
typename _ForwardIterator1,
typename _BinaryPredicate = equal_to<>>
1223 class default_searcher
1226 _GLIBCXX20_CONSTEXPR
1227 default_searcher(_ForwardIterator1 __pat_first,
1228 _ForwardIterator1 __pat_last,
1229 _BinaryPredicate __pred = _BinaryPredicate())
1230 : _M_m(__pat_first, __pat_last,
std::
move(__pred))
1233 template<
typename _ForwardIterator2>
1234 _GLIBCXX20_CONSTEXPR
1235 pair<_ForwardIterator2, _ForwardIterator2>
1236 operator()(_ForwardIterator2 __first, _ForwardIterator2 __last)
const
1238 _ForwardIterator2 __first_ret =
1239 std::search(__first, __last, std::get<0>(_M_m), std::get<1>(_M_m),
1241 auto __ret = std::make_pair(__first_ret, __first_ret);
1242 if (__ret.first != __last)
1244 std::get<1>(_M_m)));
1249 tuple<_ForwardIterator1, _ForwardIterator1, _BinaryPredicate> _M_m;
1252#ifdef __cpp_lib_boyer_moore_searcher
1254 template<
typename _Key,
typename _Tp,
typename _Hash,
typename _Pred>
1255 struct __boyer_moore_map_base
1257 template<
typename _RAIter>
1258 __boyer_moore_map_base(_RAIter __pat,
size_t __patlen,
1259 _Hash&& __hf, _Pred&& __pred)
1263 for (__diff_type __i = 0; __i < __patlen - 1; ++__i)
1264 _M_bad_char[__pat[__i]] = __patlen - 1 - __i;
1267 using __diff_type = _Tp;
1270 _M_lookup(_Key __key, __diff_type __not_found)
const
1272 auto __iter = _M_bad_char.find(__key);
1273 if (__iter == _M_bad_char.end())
1275 return __iter->second;
1279 _M_pred()
const {
return _M_bad_char.key_eq(); }
1281 _GLIBCXX_STD_C::unordered_map<_Key, _Tp, _Hash, _Pred> _M_bad_char;
1284 template<
typename _Tp,
size_t _Len,
typename _Pred>
1285 struct __boyer_moore_array_base
1287 template<
typename _RAIter,
typename _Unused>
1288 __boyer_moore_array_base(_RAIter __pat,
size_t __patlen,
1289 _Unused&&, _Pred&& __pred)
1290 : _M_bad_char{ array<_Tp, _Len>{},
std::move(__pred) }
1292 std::get<0>(_M_bad_char).fill(__patlen);
1294 for (__diff_type __i = 0; __i < __patlen - 1; ++__i)
1296 auto __ch = __pat[__i];
1298 auto __uch =
static_cast<_UCh
>(__ch);
1299 std::get<0>(_M_bad_char)[__uch] = __patlen - 1 - __i;
1303 using __diff_type = _Tp;
1305 template<
typename _Key>
1307 _M_lookup(_Key __key, __diff_type __not_found)
const
1309 auto __ukey =
static_cast<make_unsigned_t<_Key>
>(__key);
1312 return std::get<0>(_M_bad_char)[__ukey];
1316 _M_pred()
const {
return std::get<1>(_M_bad_char); }
1318 tuple<array<_Tp, _Len>, _Pred> _M_bad_char;
1323 template<
typename _RAIter,
typename _Hash,
typename _Pred,
1324 typename _Val =
typename iterator_traits<_RAIter>::value_type,
1325 typename _Diff =
typename iterator_traits<_RAIter>::difference_type>
1326 using __boyer_moore_base_t
1327 = __conditional_t<__is_byte_like<_Val, _Pred>::value,
1328 __boyer_moore_array_base<_Diff, 256, _Pred>,
1329 __boyer_moore_map_base<_Val, _Diff, _Hash, _Pred>>;
1331 template<
typename _RAIter,
typename _Hash
1332 = hash<typename iterator_traits<_RAIter>::value_type>,
1333 typename _BinaryPredicate = equal_to<>>
1334 class boyer_moore_searcher
1335 : __boyer_moore_base_t<_RAIter, _Hash, _BinaryPredicate>
1337 using _Base = __boyer_moore_base_t<_RAIter, _Hash, _BinaryPredicate>;
1338 using typename _Base::__diff_type;
1341 boyer_moore_searcher(_RAIter __pat_first, _RAIter __pat_last,
1342 _Hash __hf = _Hash(),
1343 _BinaryPredicate __pred = _BinaryPredicate());
1345 template<
typename _RandomAccessIterator2>
1346 pair<_RandomAccessIterator2, _RandomAccessIterator2>
1347 operator()(_RandomAccessIterator2 __first,
1348 _RandomAccessIterator2 __last)
const;
1352 _M_is_prefix(_RAIter __word, __diff_type __len,
1355 const auto& __pred = this->_M_pred();
1356 __diff_type __suffixlen = __len - __pos;
1357 for (__diff_type __i = 0; __i < __suffixlen; ++__i)
1358 if (!__pred(__word[__i], __word[__pos + __i]))
1364 _M_suffix_length(_RAIter __word, __diff_type __len,
1367 const auto& __pred = this->_M_pred();
1368 __diff_type __i = 0;
1369 while (__pred(__word[__pos - __i], __word[__len - 1 - __i])
1377 template<
typename _Tp>
1379 _M_bad_char_shift(_Tp __c)
const
1380 {
return this->_M_lookup(__c, _M_pat_end - _M_pat); }
1384 _GLIBCXX_STD_C::vector<__diff_type> _M_good_suffix;
1387 template<
typename _RAIter,
typename _Hash
1388 = hash<typename iterator_traits<_RAIter>::value_type>,
1389 typename _BinaryPredicate = equal_to<>>
1390 class boyer_moore_horspool_searcher
1391 : __boyer_moore_base_t<_RAIter, _Hash, _BinaryPredicate>
1393 using _Base = __boyer_moore_base_t<_RAIter, _Hash, _BinaryPredicate>;
1394 using typename _Base::__diff_type;
1397 boyer_moore_horspool_searcher(_RAIter __pat,
1399 _Hash __hf = _Hash(),
1400 _BinaryPredicate __pred
1401 = _BinaryPredicate())
1402 : _Base(__pat, __pat_end - __pat,
std::
move(__hf),
std::
move(__pred)),
1403 _M_pat(__pat), _M_pat_end(__pat_end)
1406 template<
typename _RandomAccessIterator2>
1407 pair<_RandomAccessIterator2, _RandomAccessIterator2>
1408 operator()(_RandomAccessIterator2 __first,
1409 _RandomAccessIterator2 __last)
const
1411 const auto& __pred = this->_M_pred();
1412 auto __patlen = _M_pat_end - _M_pat;
1414 return std::make_pair(__first, __first);
1415 auto __len = __last - __first;
1416 while (__len >= __patlen)
1418 for (
auto __scan = __patlen - 1;
1419 __pred(__first[__scan], _M_pat[__scan]); --__scan)
1421 return std::make_pair(__first, __first + __patlen);
1422 auto __shift = _M_bad_char_shift(__first[__patlen - 1]);
1426 return std::make_pair(__last, __last);
1430 template<
typename _Tp>
1432 _M_bad_char_shift(_Tp __c)
const
1433 {
return this->_M_lookup(__c, _M_pat_end - _M_pat); }
1439 template<
typename _RAIter,
typename _Hash,
typename _BinaryPredicate>
1440 boyer_moore_searcher<_RAIter, _Hash, _BinaryPredicate>::
1441 boyer_moore_searcher(_RAIter __pat, _RAIter __pat_end,
1442 _Hash __hf, _BinaryPredicate __pred)
1443 : _Base(__pat, __pat_end - __pat,
std::
move(__hf),
std::
move(__pred)),
1444 _M_pat(__pat), _M_pat_end(__pat_end), _M_good_suffix(__pat_end - __pat)
1446 auto __patlen = __pat_end - __pat;
1449 __diff_type __last_prefix = __patlen - 1;
1450 for (__diff_type __p = __patlen - 1; __p >= 0; --__p)
1452 if (_M_is_prefix(__pat, __patlen, __p + 1))
1453 __last_prefix = __p + 1;
1454 _M_good_suffix[__p] = __last_prefix + (__patlen - 1 - __p);
1456 for (__diff_type __p = 0; __p < __patlen - 1; ++__p)
1458 auto __slen = _M_suffix_length(__pat, __patlen, __p);
1459 auto __pos = __patlen - 1 - __slen;
1460 if (!__pred(__pat[__p - __slen], __pat[__pos]))
1461 _M_good_suffix[__pos] = __patlen - 1 - __p + __slen;
1465 template<
typename _RAIter,
typename _Hash,
typename _BinaryPredicate>
1466 template<
typename _RandomAccessIterator2>
1467 pair<_RandomAccessIterator2, _RandomAccessIterator2>
1468 boyer_moore_searcher<_RAIter, _Hash, _BinaryPredicate>::
1469 operator()(_RandomAccessIterator2 __first,
1470 _RandomAccessIterator2 __last)
const
1472 auto __patlen = _M_pat_end - _M_pat;
1474 return std::make_pair(__first, __first);
1475 const auto& __pred = this->_M_pred();
1476 __diff_type __i = __patlen - 1;
1477 auto __stringlen = __last - __first;
1478 while (__i < __stringlen)
1480 __diff_type __j = __patlen - 1;
1481 while (__j >= 0 && __pred(__first[__i], _M_pat[__j]))
1488 const auto __match = __first + __i + 1;
1489 return std::make_pair(__match, __match + __patlen);
1491 __i +=
std::max(_M_bad_char_shift(__first[__i]),
1492 _M_good_suffix[__j]);
1494 return std::make_pair(__last, __last);
1502_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.