43#ifndef _GLIBCXX_FUNCTIONAL
44#define _GLIBCXX_FUNCTIONAL 1
47#pragma GCC system_header
53#if __cplusplus >= 201103L
63#if __cplusplus >= 201703L
71#if __cplusplus >= 202002L
75#if __cplusplus > 202002L && _GLIBCXX_HOSTED
79#define __glibcxx_want_boyer_moore_searcher
80#define __glibcxx_want_bind_front
81#define __glibcxx_want_bind_back
82#define __glibcxx_want_constexpr_functional
83#define __glibcxx_want_invoke
84#define __glibcxx_want_invoke_r
85#define __glibcxx_want_move_only_function
86#define __glibcxx_want_not_fn
87#define __glibcxx_want_ranges
88#define __glibcxx_want_reference_wrapper
89#define __glibcxx_want_transparent_operators
94namespace std _GLIBCXX_VISIBILITY(default)
96_GLIBCXX_BEGIN_NAMESPACE_VERSION
104#ifdef __cpp_lib_invoke
117 template<
typename _Callable,
typename... _Args>
118 inline _GLIBCXX20_CONSTEXPR invoke_result_t<_Callable, _Args...>
119 invoke(_Callable&& __fn, _Args&&... __args)
120 noexcept(is_nothrow_invocable_v<_Callable, _Args...>)
123 std::forward<_Args>(__args)...);
127#ifdef __cpp_lib_invoke_r
136 template<
typename _Res,
typename _Callable,
typename... _Args>
137 requires is_invocable_r_v<_Res, _Callable, _Args...>
139 invoke_r(_Callable&& __fn, _Args&&... __args)
140 noexcept(is_nothrow_invocable_r_v<_Res, _Callable, _Args...>)
142 return std::__invoke_r<_Res>(std::forward<_Callable>(__fn),
143 std::forward<_Args>(__args)...);
149#if __cplusplus >= 201103L
150 template<
typename _MemFunPtr,
151 bool __is_mem_fn = is_member_function_pointer<_MemFunPtr>::value>
153 :
public _Mem_fn_traits<_MemFunPtr>::__maybe_type
155 using _Traits = _Mem_fn_traits<_MemFunPtr>;
157 using _Arity =
typename _Traits::__arity;
158 using _Varargs =
typename _Traits::__vararg;
160 template<
typename _Func,
typename... _BoundArgs>
161 friend struct _Bind_check_arity;
167 using result_type =
typename _Traits::__result_type;
170 _Mem_fn_base(_MemFunPtr __pmf) noexcept : _M_pmf(__pmf) { }
172 template<
typename... _Args>
175 operator()(_Args&&... __args)
const
178 ->
decltype(
std::__invoke(_M_pmf, std::forward<_Args>(__args)...))
179 {
return std::__invoke(_M_pmf, std::forward<_Args>(__args)...); }
183 template<
typename _MemObjPtr>
184 class _Mem_fn_base<_MemObjPtr, false>
186 using _Arity = integral_constant<size_t, 0>;
189 template<
typename _Func,
typename... _BoundArgs>
190 friend struct _Bind_check_arity;
196 _Mem_fn_base(_MemObjPtr __pm) noexcept : _M_pm(__pm) { }
198 template<
typename _Tp>
201 operator()(_Tp&& __obj)
const
202 noexcept(
noexcept(
std::__invoke(_M_pm, std::forward<_Tp>(__obj))))
207 template<
typename _MemberPo
inter>
210 template<
typename _Res,
typename _Class>
211 struct _Mem_fn<_Res _Class::*>
212 : _Mem_fn_base<_Res _Class::*>
214 using _Mem_fn_base<_Res _Class::*>::_Mem_fn_base;
243 template<
typename _Tp,
typename _Class>
245 inline _Mem_fn<_Tp _Class::*>
248 return _Mem_fn<_Tp _Class::*>(__pm);
262 template<
typename _Tp>
274 template<
typename _Tp>
279#if __cplusplus > 201402L
280 template <
typename _Tp>
inline constexpr bool is_bind_expression_v
282 template <
typename _Tp>
inline constexpr int is_placeholder_v
291 namespace placeholders
297#if __cpp_inline_variables
298# define _GLIBCXX_PLACEHOLDER inline
300# define _GLIBCXX_PLACEHOLDER extern
333#undef _GLIBCXX_PLACEHOLDER
355 template<std::
size_t __i,
typename _Tuple>
356 using _Safe_tuple_element_t
357 =
typename enable_if<(__i < tuple_size<_Tuple>::value),
358 tuple_element<__i, _Tuple>>::type::type;
371 template<
typename _Arg,
372 bool _IsBindExp = is_bind_expression<_Arg>::value,
373 bool _IsPlaceholder = (is_placeholder<_Arg>::value > 0)>
381 template<
typename _Tp>
382 class _Mu<reference_wrapper<_Tp>, false, false>
389 template<
typename _CVRef,
typename _Tuple>
392 operator()(_CVRef& __arg, _Tuple&)
const volatile
393 {
return __arg.get(); }
402 template<
typename _Arg>
403 class _Mu<_Arg, true, false>
406 template<
typename _CVArg,
typename... _Args>
409 operator()(_CVArg& __arg,
410 tuple<_Args...>& __tuple)
const volatile
411 ->
decltype(__arg(declval<_Args>()...))
414 typedef typename _Build_index_tuple<
sizeof...(_Args)>::__type
416 return this->__call(__arg, __tuple, _Indexes());
422 template<
typename _CVArg,
typename... _Args, std::size_t... _Indexes>
425 __call(_CVArg& __arg, tuple<_Args...>& __tuple,
426 const _Index_tuple<_Indexes...>&)
const volatile
427 ->
decltype(__arg(declval<_Args>()...))
429 return __arg(std::get<_Indexes>(
std::move(__tuple))...);
438 template<
typename _Arg>
439 class _Mu<_Arg, false, true>
442 template<
typename _Tuple>
444 _Safe_tuple_element_t<(is_placeholder<_Arg>::value - 1), _Tuple>&&
445 operator()(
const volatile _Arg&, _Tuple& __tuple)
const volatile
448 ::std::get<(is_placeholder<_Arg>::value - 1)>(
std::move(__tuple));
457 template<
typename _Arg>
458 class _Mu<_Arg, false, false>
461 template<
typename _CVArg,
typename _Tuple>
464 operator()(_CVArg&& __arg, _Tuple&)
const volatile
465 {
return std::forward<_CVArg>(__arg); }
469 template<std::size_t _Ind,
typename... _Tp>
471 __volget(
volatile tuple<_Tp...>& __tuple)
472 -> __tuple_element_t<_Ind, tuple<_Tp...>>
volatile&
473 {
return std::get<_Ind>(
const_cast<tuple<_Tp...
>&>(__tuple)); }
476 template<std::size_t _Ind,
typename... _Tp>
478 __volget(
const volatile tuple<_Tp...>& __tuple)
479 -> __tuple_element_t<_Ind, tuple<_Tp...>>
const volatile&
480 {
return std::get<_Ind>(
const_cast<const tuple<_Tp...
>&>(__tuple)); }
484#if __cplusplus == 201703L && _GLIBCXX_USE_DEPRECATED
485# define _GLIBCXX_VOLATILE_BIND
488# define _GLIBCXX_DEPR_BIND \
489 [[deprecated("std::bind does not support volatile in C++17")]]
490#elif __cplusplus < 201703L
491# define _GLIBCXX_VOLATILE_BIND
492# define _GLIBCXX_DEPR_BIND
496 template<
typename _Signature>
499 template<
typename _Functor,
typename... _Bound_args>
500 class _Bind<_Functor(_Bound_args...)>
501 :
public _Weak_result_type<_Functor>
503 typedef typename _Build_index_tuple<
sizeof...(_Bound_args)>::__type
507 tuple<_Bound_args...> _M_bound_args;
510 template<
typename _Result,
typename... _Args, std::size_t... _Indexes>
516 _Mu<_Bound_args>()(std::get<_Indexes>(_M_bound_args), __args)...
521 template<
typename _Result,
typename... _Args, std::size_t... _Indexes>
527 _Mu<_Bound_args>()(std::get<_Indexes>(_M_bound_args), __args)...
531#ifdef _GLIBCXX_VOLATILE_BIND
533 template<
typename _Result,
typename... _Args, std::size_t... _Indexes>
535 __call_v(tuple<_Args...>&& __args,
536 _Index_tuple<_Indexes...>)
volatile
539 _Mu<_Bound_args>()(__volget<_Indexes>(_M_bound_args), __args)...
544 template<
typename _Result,
typename... _Args, std::size_t... _Indexes>
546 __call_c_v(tuple<_Args...>&& __args,
547 _Index_tuple<_Indexes...>)
const volatile
550 _Mu<_Bound_args>()(__volget<_Indexes>(_M_bound_args), __args)...
555 template<
typename _BoundArg,
typename _CallArgs>
556 using _Mu_type =
decltype(
557 _Mu<typename remove_cv<_BoundArg>::type>()(
558 std::declval<_BoundArg&>(), std::declval<_CallArgs&>()) );
560 template<
typename _Fn,
typename _CallArgs,
typename... _BArgs>
562 = __invoke_result_t<_Fn&, _Mu_type<_BArgs, _CallArgs>&&...>;
564 template<
typename _CallArgs>
565 using _Res_type = _Res_type_impl<_Functor, _CallArgs, _Bound_args...>;
567 template<
typename _CallArgs>
568 using __dependent =
typename
569 enable_if<bool(tuple_size<_CallArgs>::value+1), _Functor>::type;
571 template<
typename _CallArgs,
template<
class>
class __cv_quals>
572 using _Res_type_cv = _Res_type_impl<
573 typename __cv_quals<__dependent<_CallArgs>>::type,
575 typename __cv_quals<_Bound_args>::type...>;
578 template<
typename... _Args>
579 explicit _GLIBCXX20_CONSTEXPR
580 _Bind(
const _Functor& __f, _Args&&... __args)
581 : _M_f(__f), _M_bound_args(
std::
forward<_Args>(__args)...)
584 template<
typename... _Args>
585 explicit _GLIBCXX20_CONSTEXPR
586 _Bind(_Functor&& __f, _Args&&... __args)
590 _Bind(
const _Bind&) =
default;
591 _Bind(_Bind&&) =
default;
594 template<
typename... _Args,
595 typename _Result = _Res_type<tuple<_Args...>>>
598 operator()(_Args&&... __args)
600 return this->__call<_Result>(
606 template<
typename... _Args,
607 typename _Result = _Res_type_cv<tuple<_Args...>, add_const>>
610 operator()(_Args&&... __args)
const
612 return this->__call_c<_Result>(
617#ifdef _GLIBCXX_VOLATILE_BIND
619 template<
typename... _Args,
620 typename _Result = _Res_type_cv<tuple<_Args...>, add_volatile>>
623 operator()(_Args&&... __args)
volatile
625 return this->__call_v<_Result>(
631 template<
typename... _Args,
632 typename _Result = _Res_type_cv<tuple<_Args...>, add_cv>>
635 operator()(_Args&&... __args)
const volatile
637 return this->__call_c_v<_Result>(
645 template<
typename _Result,
typename _Signature>
648 template<
typename _Result,
typename _Functor,
typename... _Bound_args>
651 typedef typename _Build_index_tuple<
sizeof...(_Bound_args)>::__type
655 tuple<_Bound_args...> _M_bound_args;
658 template<
typename _Res,
typename... _Args, std::size_t... _Indexes>
663 return std::__invoke_r<_Res>(_M_f, _Mu<_Bound_args>()
664 (std::get<_Indexes>(_M_bound_args), __args)...);
668 template<
typename _Res,
typename... _Args, std::size_t... _Indexes>
673 return std::__invoke_r<_Res>(_M_f, _Mu<_Bound_args>()
674 (std::get<_Indexes>(_M_bound_args), __args)...);
677#ifdef _GLIBCXX_VOLATILE_BIND
679 template<
typename _Res,
typename... _Args, std::size_t... _Indexes>
683 return std::__invoke_r<_Res>(_M_f, _Mu<_Bound_args>()
684 (__volget<_Indexes>(_M_bound_args), __args)...);
688 template<
typename _Res,
typename... _Args, std::size_t... _Indexes>
691 _Index_tuple<_Indexes...>)
const volatile
693 return std::__invoke_r<_Res>(_M_f, _Mu<_Bound_args>()
694 (__volget<_Indexes>(_M_bound_args), __args)...);
699 typedef _Result result_type;
701 template<
typename... _Args>
702 explicit _GLIBCXX20_CONSTEXPR
704 : _M_f(__f), _M_bound_args(std::forward<_Args>(__args)...)
707 template<
typename... _Args>
708 explicit _GLIBCXX20_CONSTEXPR
710 : _M_f(
std::move(__f)), _M_bound_args(std::forward<_Args>(__args)...)
717 template<
typename... _Args>
720 operator()(_Args&&... __args)
722 return this->__call<_Result>(
728 template<
typename... _Args>
731 operator()(_Args&&... __args)
const
733 return this->__call<_Result>(
738#ifdef _GLIBCXX_VOLATILE_BIND
740 template<
typename... _Args>
743 operator()(_Args&&... __args)
volatile
745 return this->__call<_Result>(
751 template<
typename... _Args>
754 operator()(_Args&&... __args)
const volatile
756 return this->__call<_Result>(
761 template<
typename... _Args>
762 void operator()(_Args&&...)
const volatile =
delete;
766#undef _GLIBCXX_VOLATILE_BIND
767#undef _GLIBCXX_DEPR_BIND
773 template<
typename _Signature>
781 template<
typename _Signature>
789 template<
typename _Signature>
797 template<
typename _Signature>
805 template<
typename _Result,
typename _Signature>
813 template<
typename _Result,
typename _Signature>
821 template<
typename _Result,
typename _Signature>
829 template<
typename _Result,
typename _Signature>
833 template<
typename _Func,
typename... _BoundArgs>
834 struct _Bind_check_arity { };
836 template<
typename _Ret,
typename... _Args,
typename... _BoundArgs>
837 struct _Bind_check_arity<_Ret (*)(_Args...), _BoundArgs...>
839 static_assert(
sizeof...(_BoundArgs) ==
sizeof...(_Args),
840 "Wrong number of arguments for function");
843 template<
typename _Ret,
typename... _Args,
typename... _BoundArgs>
844 struct _Bind_check_arity<_Ret (*)(_Args..., ...), _BoundArgs...>
846 static_assert(
sizeof...(_BoundArgs) >=
sizeof...(_Args),
847 "Wrong number of arguments for function");
850 template<
typename _Tp,
typename _Class,
typename... _BoundArgs>
851 struct _Bind_check_arity<_Tp _Class::*, _BoundArgs...>
853 using _Arity =
typename _Mem_fn<_Tp _Class::*>::_Arity;
854 using _Varargs =
typename _Mem_fn<_Tp _Class::*>::_Varargs;
855 static_assert(_Varargs::value
856 ?
sizeof...(_BoundArgs) >= _Arity::value + 1
857 : sizeof...(_BoundArgs) == _Arity::value + 1,
858 "Wrong number of arguments for pointer-to-member");
864 template<typename _Tp, typename _Tp2 = typename decay<_Tp>::type>
865 using __is_socketlike = __or_<is_integral<_Tp2>, is_enum<_Tp2>>;
867 template<
bool _SocketLike,
typename _Func,
typename... _BoundArgs>
869 : _Bind_check_arity<typename decay<_Func>::type, _BoundArgs...>
871 typedef typename decay<_Func>::type __func_type;
872 typedef _Bind<__func_type(
typename decay<_BoundArgs>::type...)> type;
878 template<
typename _Func,
typename... _BoundArgs>
879 struct _Bind_helper<true, _Func, _BoundArgs...>
887 template<
typename _Func,
typename... _BoundArgs>
888 inline _GLIBCXX20_CONSTEXPR
typename
889 _Bind_helper<__is_socketlike<_Func>::value, _Func, _BoundArgs...>::type
890 bind(_Func&& __f, _BoundArgs&&... __args)
892 typedef _Bind_helper<
false, _Func, _BoundArgs...> __helper_type;
893 return typename __helper_type::type(std::forward<_Func>(__f),
894 std::forward<_BoundArgs>(__args)...);
897 template<
typename _Result,
typename _Func,
typename... _BoundArgs>
898 struct _Bindres_helper
899 : _Bind_check_arity<typename decay<_Func>::type, _BoundArgs...>
901 typedef typename decay<_Func>::type __functor_type;
902 typedef _Bind_result<_Result,
903 __functor_type(
typename decay<_BoundArgs>::type...)>
912 template<
typename _Result,
typename _Func,
typename... _BoundArgs>
913 inline _GLIBCXX20_CONSTEXPR
914 typename _Bindres_helper<_Result, _Func, _BoundArgs...>::type
915 bind(_Func&& __f, _BoundArgs&&... __args)
917 typedef _Bindres_helper<_Result, _Func, _BoundArgs...> __helper_type;
918 return typename __helper_type::type(std::forward<_Func>(__f),
919 std::forward<_BoundArgs>(__args)...);
922#ifdef __cpp_lib_bind_front
924 template<
typename _Fd,
typename... _BoundArgs>
927 static_assert(is_move_constructible_v<_Fd>);
928 static_assert((is_move_constructible_v<_BoundArgs> && ...));
932 template<
typename _Fn,
typename... _Args>
934 _Bind_front(
int, _Fn&& __fn, _Args&&... __args)
935 noexcept(__and_<is_nothrow_constructible<_Fd, _Fn>,
936 is_nothrow_constructible<_BoundArgs, _Args>...>::value)
937 : _M_fd(
std::forward<_Fn>(__fn)),
938 _M_bound_args(
std::forward<_Args>(__args)...)
939 {
static_assert(
sizeof...(_Args) ==
sizeof...(_BoundArgs)); }
941#if __cpp_explicit_this_parameter
942 template<
typename _Self,
typename... _CallArgs>
944 invoke_result_t<__like_t<_Self, _Fd>, __like_t<_Self, _BoundArgs>..., _CallArgs...>
945 operator()(
this _Self&& __self, _CallArgs&&... __call_args)
946 noexcept(is_nothrow_invocable_v<__like_t<_Self, _Fd>,
947 __like_t<_Self, _BoundArgs>..., _CallArgs...>)
949 return _S_call(__like_t<_Self, _Bind_front>(__self), _BoundIndices(),
950 std::forward<_CallArgs>(__call_args)...);
953 template<
typename... _CallArgs>
956 invoke_result_t<_Fd&, _BoundArgs&..., _CallArgs...>
957 operator()(_CallArgs&&... __call_args) &
958 noexcept(is_nothrow_invocable_v<_Fd&, _BoundArgs&..., _CallArgs...>)
960 return _S_call(*
this, _BoundIndices(),
961 std::forward<_CallArgs>(__call_args)...);
964 template<
typename... _CallArgs>
967 invoke_result_t<
const _Fd&,
const _BoundArgs&..., _CallArgs...>
968 operator()(_CallArgs&&... __call_args)
const &
969 noexcept(is_nothrow_invocable_v<
const _Fd&,
const _BoundArgs&...,
972 return _S_call(*
this, _BoundIndices(),
973 std::forward<_CallArgs>(__call_args)...);
976 template<
typename... _CallArgs>
979 invoke_result_t<_Fd, _BoundArgs..., _CallArgs...>
980 operator()(_CallArgs&&... __call_args) &&
981 noexcept(is_nothrow_invocable_v<_Fd, _BoundArgs..., _CallArgs...>)
983 return _S_call(
std::move(*
this), _BoundIndices(),
984 std::forward<_CallArgs>(__call_args)...);
987 template<
typename... _CallArgs>
990 invoke_result_t<
const _Fd,
const _BoundArgs..., _CallArgs...>
991 operator()(_CallArgs&&... __call_args)
const &&
992 noexcept(is_nothrow_invocable_v<
const _Fd,
const _BoundArgs...,
995 return _S_call(
std::move(*
this), _BoundIndices(),
996 std::forward<_CallArgs>(__call_args)...);
999 template<
typename... _CallArgs>
1000 void operator()(_CallArgs&&...) & =
delete;
1002 template<
typename... _CallArgs>
1003 void operator()(_CallArgs&&...) const & = delete;
1005 template<typename... _CallArgs>
1006 void operator()(_CallArgs&&...) && = delete;
1008 template<typename... _CallArgs>
1009 void operator()(_CallArgs&&...) const && = delete;
1015 template<
typename _Tp,
size_t... _Ind,
typename... _CallArgs>
1018 _S_call(_Tp&& __g, index_sequence<_Ind...>, _CallArgs&&... __call_args)
1020 return std::invoke(std::forward<_Tp>(__g)._M_fd,
1021 std::get<_Ind>(std::forward<_Tp>(__g)._M_bound_args)...,
1022 std::forward<_CallArgs>(__call_args)...);
1025 [[no_unique_address]] _Fd _M_fd;
1026 [[no_unique_address]]
std::tuple<_BoundArgs...> _M_bound_args;
1029 template<
typename _Fn,
typename... _Args>
1030 using _Bind_front_t = _Bind_front<decay_t<_Fn>, decay_t<_Args>...>;
1041 template<
typename _Fn,
typename... _Args>
1042 constexpr _Bind_front_t<_Fn, _Args...>
1043 bind_front(_Fn&& __fn, _Args&&... __args)
1044 noexcept(is_nothrow_constructible_v<_Bind_front_t<_Fn, _Args...>,
1045 int, _Fn, _Args...>)
1047 return _Bind_front_t<_Fn, _Args...>(0, std::forward<_Fn>(__fn),
1048 std::forward<_Args>(__args)...);
1052#ifdef __cpp_lib_bind_back
1053 template<
typename _Fd,
typename... _BoundArgs>
1056 static_assert(is_move_constructible_v<_Fd>);
1057 static_assert((is_move_constructible_v<_BoundArgs> && ...));
1061 template<
typename _Fn,
typename... _Args>
1063 _Bind_back(
int, _Fn&& __fn, _Args&&... __args)
1064 noexcept(__and_<is_nothrow_constructible<_Fd, _Fn>,
1065 is_nothrow_constructible<_BoundArgs, _Args>...>::value)
1067 _M_bound_args(
std::
forward<_Args>(__args)...)
1068 {
static_assert(
sizeof...(_Args) ==
sizeof...(_BoundArgs)); }
1070 template<
typename _Self,
typename... _CallArgs>
1072 invoke_result_t<__like_t<_Self, _Fd>, _CallArgs..., __like_t<_Self, _BoundArgs>...>
1073 operator()(
this _Self&& __self, _CallArgs&&... __call_args)
1074 noexcept(is_nothrow_invocable_v<__like_t<_Self, _Fd>,
1075 _CallArgs..., __like_t<_Self, _BoundArgs>...>)
1077 return _S_call(__like_t<_Self, _Bind_back>(__self), _BoundIndices(),
1078 std::forward<_CallArgs>(__call_args)...);
1084 template<
typename _Tp,
size_t... _Ind,
typename... _CallArgs>
1087 _S_call(_Tp&& __g, index_sequence<_Ind...>, _CallArgs&&... __call_args)
1089 return std::invoke(std::forward<_Tp>(__g)._M_fd,
1090 std::forward<_CallArgs>(__call_args)...,
1091 std::get<_Ind>(std::forward<_Tp>(__g)._M_bound_args)...);
1094 [[no_unique_address]] _Fd _M_fd;
1095 [[no_unique_address]]
std::tuple<_BoundArgs...> _M_bound_args;
1098 template<
typename _Fn,
typename... _Args>
1099 using _Bind_back_t = _Bind_back<decay_t<_Fn>, decay_t<_Args>...>;
1110 template<
typename _Fn,
typename... _Args>
1111 constexpr _Bind_back_t<_Fn, _Args...>
1112 bind_back(_Fn&& __fn, _Args&&... __args)
1113 noexcept(is_nothrow_constructible_v<_Bind_back_t<_Fn, _Args...>,
1114 int, _Fn, _Args...>)
1116 return _Bind_back_t<_Fn, _Args...>(0, std::forward<_Fn>(__fn),
1117 std::forward<_Args>(__args)...);
1121#if __cplusplus >= 201402L
1123 template<
typename _Fn>
1126 template<
typename _Fn2,
typename... _Args>
1127 using __inv_res_t =
typename __invoke_result<_Fn2, _Args...>::type;
1129 template<
typename _Tp>
1130 static decltype(!std::declval<_Tp>())
1131 _S_not()
noexcept(
noexcept(!std::declval<_Tp>()));
1134 template<
typename _Fn2>
1137 : _M_fn(std::forward<_Fn2>(__fn)) { }
1146#define _GLIBCXX_NOT_FN_CALL_OP( _QUALS ) \
1147 template<typename... _Args, \
1148 typename = enable_if_t<__is_invocable<_Fn _QUALS, _Args...>::value>> \
1149 _GLIBCXX20_CONSTEXPR \
1150 decltype(_S_not<__inv_res_t<_Fn _QUALS, _Args...>>()) \
1151 operator()(_Args&&... __args) _QUALS \
1152 noexcept(__is_nothrow_invocable<_Fn _QUALS, _Args...>::value \
1153 && noexcept(_S_not<__inv_res_t<_Fn _QUALS, _Args...>>())) \
1155 return !std::__invoke(std::forward< _Fn _QUALS >(_M_fn), \
1156 std::forward<_Args>(__args)...); \
1159 template<typename... _Args, \
1160 typename = enable_if_t<!__is_invocable<_Fn _QUALS, _Args...>::value>> \
1161 void operator()(_Args&&... __args) _QUALS = delete;
1163 _GLIBCXX_NOT_FN_CALL_OP( & )
1164 _GLIBCXX_NOT_FN_CALL_OP(
const & )
1165 _GLIBCXX_NOT_FN_CALL_OP( && )
1166 _GLIBCXX_NOT_FN_CALL_OP(
const && )
1167#undef _GLIBCXX_NOT_FN_CALL_OP
1173 template<
typename _Tp,
typename _Pred>
1176 template<
typename _Tp>
1177 struct __is_byte_like<_Tp, equal_to<_Tp>>
1178 : __bool_constant<sizeof(_Tp) == 1 && is_integral<_Tp>::value> { };
1180 template<
typename _Tp>
1181 struct __is_byte_like<_Tp, equal_to<void>>
1182 : __bool_constant<sizeof(_Tp) == 1 && is_integral<_Tp>::value> { };
1184#if __cplusplus >= 201703L
1186 enum class byte :
unsigned char;
1189 struct __is_byte_like<byte, equal_to<byte>>
1193 struct __is_byte_like<byte, equal_to<void>>
1198#ifdef __cpp_lib_not_fn
1211 template<
typename _Fn>
1212 _GLIBCXX20_CONSTEXPR
1217 return _Not_fn<std::decay_t<_Fn>>{std::forward<_Fn>(__fn), 0};
1221#if __cplusplus >= 201703L
1224 template<
typename _ForwardIterator1,
typename _BinaryPredicate = equal_to<>>
1225 class default_searcher
1228 _GLIBCXX20_CONSTEXPR
1229 default_searcher(_ForwardIterator1 __pat_first,
1230 _ForwardIterator1 __pat_last,
1231 _BinaryPredicate __pred = _BinaryPredicate())
1232 : _M_m(__pat_first, __pat_last,
std::
move(__pred))
1235 template<
typename _ForwardIterator2>
1236 _GLIBCXX20_CONSTEXPR
1237 pair<_ForwardIterator2, _ForwardIterator2>
1238 operator()(_ForwardIterator2 __first, _ForwardIterator2 __last)
const
1240 _ForwardIterator2 __first_ret =
1241 std::search(__first, __last, std::get<0>(_M_m), std::get<1>(_M_m),
1243 auto __ret = std::make_pair(__first_ret, __first_ret);
1244 if (__ret.first != __last)
1246 std::get<1>(_M_m)));
1251 tuple<_ForwardIterator1, _ForwardIterator1, _BinaryPredicate> _M_m;
1254#ifdef __cpp_lib_boyer_moore_searcher
1256 template<
typename _Key,
typename _Tp,
typename _Hash,
typename _Pred>
1257 struct __boyer_moore_map_base
1259 template<
typename _RAIter>
1260 __boyer_moore_map_base(_RAIter __pat,
size_t __patlen,
1261 _Hash&& __hf, _Pred&& __pred)
1265 for (__diff_type __i = 0; __i < __patlen - 1; ++__i)
1266 _M_bad_char[__pat[__i]] = __patlen - 1 - __i;
1269 using __diff_type = _Tp;
1272 _M_lookup(_Key __key, __diff_type __not_found)
const
1274 auto __iter = _M_bad_char.find(__key);
1275 if (__iter == _M_bad_char.end())
1277 return __iter->second;
1281 _M_pred()
const {
return _M_bad_char.key_eq(); }
1283 _GLIBCXX_STD_C::unordered_map<_Key, _Tp, _Hash, _Pred> _M_bad_char;
1286 template<
typename _Tp,
size_t _Len,
typename _Pred>
1287 struct __boyer_moore_array_base
1289 template<
typename _RAIter,
typename _Unused>
1290 __boyer_moore_array_base(_RAIter __pat,
size_t __patlen,
1291 _Unused&&, _Pred&& __pred)
1292 : _M_bad_char{ array<_Tp, _Len>{},
std::move(__pred) }
1294 std::get<0>(_M_bad_char).fill(__patlen);
1296 for (__diff_type __i = 0; __i < __patlen - 1; ++__i)
1298 auto __ch = __pat[__i];
1300 auto __uch =
static_cast<_UCh
>(__ch);
1301 std::get<0>(_M_bad_char)[__uch] = __patlen - 1 - __i;
1305 using __diff_type = _Tp;
1307 template<
typename _Key>
1309 _M_lookup(_Key __key, __diff_type __not_found)
const
1311 auto __ukey =
static_cast<make_unsigned_t<_Key>
>(__key);
1314 return std::get<0>(_M_bad_char)[__ukey];
1318 _M_pred()
const {
return std::get<1>(_M_bad_char); }
1320 tuple<array<_Tp, _Len>, _Pred> _M_bad_char;
1325 template<
typename _RAIter,
typename _Hash,
typename _Pred,
1326 typename _Val =
typename iterator_traits<_RAIter>::value_type,
1327 typename _Diff =
typename iterator_traits<_RAIter>::difference_type>
1328 using __boyer_moore_base_t
1329 = __conditional_t<__is_byte_like<_Val, _Pred>::value,
1330 __boyer_moore_array_base<_Diff, 256, _Pred>,
1331 __boyer_moore_map_base<_Val, _Diff, _Hash, _Pred>>;
1333 template<
typename _RAIter,
typename _Hash
1334 = hash<typename iterator_traits<_RAIter>::value_type>,
1335 typename _BinaryPredicate = equal_to<>>
1336 class boyer_moore_searcher
1337 : __boyer_moore_base_t<_RAIter, _Hash, _BinaryPredicate>
1339 using _Base = __boyer_moore_base_t<_RAIter, _Hash, _BinaryPredicate>;
1340 using typename _Base::__diff_type;
1343 boyer_moore_searcher(_RAIter __pat_first, _RAIter __pat_last,
1344 _Hash __hf = _Hash(),
1345 _BinaryPredicate __pred = _BinaryPredicate());
1347 template<
typename _RandomAccessIterator2>
1348 pair<_RandomAccessIterator2, _RandomAccessIterator2>
1349 operator()(_RandomAccessIterator2 __first,
1350 _RandomAccessIterator2 __last)
const;
1354 _M_is_prefix(_RAIter __word, __diff_type __len,
1357 const auto& __pred = this->_M_pred();
1358 __diff_type __suffixlen = __len - __pos;
1359 for (__diff_type __i = 0; __i < __suffixlen; ++__i)
1360 if (!__pred(__word[__i], __word[__pos + __i]))
1366 _M_suffix_length(_RAIter __word, __diff_type __len,
1369 const auto& __pred = this->_M_pred();
1370 __diff_type __i = 0;
1371 while (__pred(__word[__pos - __i], __word[__len - 1 - __i])
1379 template<
typename _Tp>
1381 _M_bad_char_shift(_Tp __c)
const
1382 {
return this->_M_lookup(__c, _M_pat_end - _M_pat); }
1386 _GLIBCXX_STD_C::vector<__diff_type> _M_good_suffix;
1389 template<
typename _RAIter,
typename _Hash
1390 = hash<typename iterator_traits<_RAIter>::value_type>,
1391 typename _BinaryPredicate = equal_to<>>
1392 class boyer_moore_horspool_searcher
1393 : __boyer_moore_base_t<_RAIter, _Hash, _BinaryPredicate>
1395 using _Base = __boyer_moore_base_t<_RAIter, _Hash, _BinaryPredicate>;
1396 using typename _Base::__diff_type;
1399 boyer_moore_horspool_searcher(_RAIter __pat,
1401 _Hash __hf = _Hash(),
1402 _BinaryPredicate __pred
1403 = _BinaryPredicate())
1404 : _Base(__pat, __pat_end - __pat,
std::
move(__hf),
std::
move(__pred)),
1405 _M_pat(__pat), _M_pat_end(__pat_end)
1408 template<
typename _RandomAccessIterator2>
1409 pair<_RandomAccessIterator2, _RandomAccessIterator2>
1410 operator()(_RandomAccessIterator2 __first,
1411 _RandomAccessIterator2 __last)
const
1413 const auto& __pred = this->_M_pred();
1414 auto __patlen = _M_pat_end - _M_pat;
1416 return std::make_pair(__first, __first);
1417 auto __len = __last - __first;
1418 while (__len >= __patlen)
1420 for (
auto __scan = __patlen - 1;
1421 __pred(__first[__scan], _M_pat[__scan]); --__scan)
1423 return std::make_pair(__first, __first + __patlen);
1424 auto __shift = _M_bad_char_shift(__first[__patlen - 1]);
1428 return std::make_pair(__last, __last);
1432 template<
typename _Tp>
1434 _M_bad_char_shift(_Tp __c)
const
1435 {
return this->_M_lookup(__c, _M_pat_end - _M_pat); }
1441 template<
typename _RAIter,
typename _Hash,
typename _BinaryPredicate>
1442 boyer_moore_searcher<_RAIter, _Hash, _BinaryPredicate>::
1443 boyer_moore_searcher(_RAIter __pat, _RAIter __pat_end,
1444 _Hash __hf, _BinaryPredicate __pred)
1445 : _Base(__pat, __pat_end - __pat,
std::
move(__hf),
std::
move(__pred)),
1446 _M_pat(__pat), _M_pat_end(__pat_end), _M_good_suffix(__pat_end - __pat)
1448 auto __patlen = __pat_end - __pat;
1451 __diff_type __last_prefix = __patlen - 1;
1452 for (__diff_type __p = __patlen - 1; __p >= 0; --__p)
1454 if (_M_is_prefix(__pat, __patlen, __p + 1))
1455 __last_prefix = __p + 1;
1456 _M_good_suffix[__p] = __last_prefix + (__patlen - 1 - __p);
1458 for (__diff_type __p = 0; __p < __patlen - 1; ++__p)
1460 auto __slen = _M_suffix_length(__pat, __patlen, __p);
1461 auto __pos = __patlen - 1 - __slen;
1462 if (!__pred(__pat[__p - __slen], __pat[__pos]))
1463 _M_good_suffix[__pos] = __patlen - 1 - __p + __slen;
1467 template<
typename _RAIter,
typename _Hash,
typename _BinaryPredicate>
1468 template<
typename _RandomAccessIterator2>
1469 pair<_RandomAccessIterator2, _RandomAccessIterator2>
1470 boyer_moore_searcher<_RAIter, _Hash, _BinaryPredicate>::
1471 operator()(_RandomAccessIterator2 __first,
1472 _RandomAccessIterator2 __last)
const
1474 auto __patlen = _M_pat_end - _M_pat;
1476 return std::make_pair(__first, __first);
1477 const auto& __pred = this->_M_pred();
1478 __diff_type __i = __patlen - 1;
1479 auto __stringlen = __last - __first;
1480 while (__i < __stringlen)
1482 __diff_type __j = __patlen - 1;
1483 while (__j >= 0 && __pred(__first[__i], _M_pat[__j]))
1490 const auto __match = __first + __i + 1;
1491 return std::make_pair(__match, __match + __patlen);
1493 __i +=
std::max(_M_bad_char_shift(__first[__i]),
1494 _M_good_suffix[__j]);
1496 return std::make_pair(__last, __last);
1504_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.