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
499#if _GLIBCXX_EXPLICIT_THIS_PARAMETER
501 template<
typename _Tp,
typename _Up>
503 {
using type = _Up; };
505 template<
typename _Tp,
typename _Up>
506 struct __cv_like<const _Tp, _Up>
507 {
using type =
const _Up; };
509 template<
typename _Tp,
typename _Up>
510 struct __cv_like<volatile _Tp, _Up>
511 {
using type =
volatile _Up; };
513 template<
typename _Tp,
typename _Up>
514 struct __cv_like<const volatile _Tp, _Up>
515 {
using type =
const volatile _Up; };
517 template<
typename _Tp,
typename _Up>
518 using __cv_like_t =
typename __cv_like<_Tp, _Up>::type;
522 template<
typename _Signature>
525 template<
typename _Functor,
typename... _Bound_args>
526 class _Bind<_Functor(_Bound_args...)>
527 :
public _Weak_result_type<_Functor>
529 typedef typename _Build_index_tuple<
sizeof...(_Bound_args)>::__type
533 tuple<_Bound_args...> _M_bound_args;
536 template<
typename _Result,
typename... _Args, std::size_t... _Indexes>
542 _Mu<_Bound_args>()(std::get<_Indexes>(_M_bound_args), __args)...
547 template<
typename _Result,
typename... _Args, std::size_t... _Indexes>
553 _Mu<_Bound_args>()(std::get<_Indexes>(_M_bound_args), __args)...
557#ifdef _GLIBCXX_VOLATILE_BIND
559 template<
typename _Result,
typename... _Args, std::size_t... _Indexes>
561 __call_v(tuple<_Args...>&& __args,
562 _Index_tuple<_Indexes...>)
volatile
565 _Mu<_Bound_args>()(__volget<_Indexes>(_M_bound_args), __args)...
570 template<
typename _Result,
typename... _Args, std::size_t... _Indexes>
572 __call_c_v(tuple<_Args...>&& __args,
573 _Index_tuple<_Indexes...>)
const volatile
576 _Mu<_Bound_args>()(__volget<_Indexes>(_M_bound_args), __args)...
581 template<
typename _BoundArg,
typename _CallArgs>
582 using _Mu_type =
decltype(
583 _Mu<typename remove_cv<_BoundArg>::type>()(
586 template<
typename _Fn,
typename _CallArgs,
typename... _BArgs>
588 = __invoke_result_t<_Fn&, _Mu_type<_BArgs, _CallArgs>&&...>;
590#if !_GLIBCXX_EXPLICIT_THIS_PARAMETER
591 template<
typename _CallArgs>
592 using _Res_type = _Res_type_impl<_Functor, _CallArgs, _Bound_args...>;
594 template<
typename _CallArgs>
595 using __dependent =
typename
596 enable_if<bool(tuple_size<_CallArgs>::value+1), _Functor>::type;
598 template<
typename _CallArgs,
template<
class>
class __cv_quals>
599 using _Res_type_cv = _Res_type_impl<
600 typename __cv_quals<__dependent<_CallArgs>>::type,
602 typename __cv_quals<_Bound_args>::type...>;
606 template<
typename... _Args>
607 explicit _GLIBCXX20_CONSTEXPR
608 _Bind(
const _Functor& __f, _Args&&... __args)
609 : _M_f(__f), _M_bound_args(std::
forward<_Args>(__args)...)
612 template<
typename... _Args>
613 explicit _GLIBCXX20_CONSTEXPR
614 _Bind(_Functor&& __f, _Args&&... __args)
615 : _M_f(std::
move(__f)), _M_bound_args(std::
forward<_Args>(__args)...)
618 _Bind(
const _Bind&) =
default;
619 _Bind(_Bind&&) =
default;
621#if _GLIBCXX_EXPLICIT_THIS_PARAMETER
622# pragma GCC diagnostic push
623# pragma GCC diagnostic ignored "-Wc++17-extensions"
624# pragma GCC diagnostic ignored "-Wc++23-extensions"
625 template<
typename... _Args,
627 typename _Self_nonref =
typename remove_reference<_Self>::type,
628 __enable_if_t<!is_volatile<_Self_nonref>::value,
int> = 0,
630 = _Res_type_impl<__cv_like_t<_Self_nonref, _Functor>,
632 __cv_like_t<_Self_nonref, _Bound_args>...>>
635 operator()(
this _Self&& __self, _Args&&... __args)
637 using _Bind_ref = __cv_like_t<_Self_nonref, _Bind>&;
638 if constexpr (is_const<_Self_nonref>::value)
639 return _Bind_ref(__self)
644 return _Bind_ref(__self)
650# if defined(_GLIBCXX_VOLATILE_BIND)
651 template<
typename... _Args,
653 typename _Self_nonref =
typename remove_reference<_Self>::type,
654 __enable_if_t<is_volatile<_Self_nonref>::value,
int> = 0,
656 = _Res_type_impl<__cv_like_t<_Self_nonref, _Functor>,
658 __cv_like_t<_Self_nonref, _Bound_args>...>>
661 operator()(
this _Self&& __self, _Args&&... __args)
663 using _Bind_ref = __cv_like_t<_Self_nonref, _Bind>&;
664 if constexpr (is_const<_Self_nonref>::value)
665 return _Bind_ref(__self)
670 return _Bind_ref(__self)
676# pragma GCC diagnostic pop
679 template<
typename... _Args,
680 typename _Result = _Res_type<tuple<_Args...>>>
683 operator()(_Args&&... __args)
685 return this->__call<_Result>(
691 template<
typename... _Args,
692 typename _Result = _Res_type_cv<tuple<_Args...>, add_const>>
695 operator()(_Args&&... __args)
const
697 return this->__call_c<_Result>(
702#ifdef _GLIBCXX_VOLATILE_BIND
704 template<
typename... _Args,
705 typename _Result = _Res_type_cv<tuple<_Args...>, add_volatile>>
708 operator()(_Args&&... __args)
volatile
710 return this->__call_v<_Result>(
716 template<
typename... _Args,
717 typename _Result = _Res_type_cv<tuple<_Args...>, add_cv>>
720 operator()(_Args&&... __args)
const volatile
722 return this->__call_c_v<_Result>(
731 template<
typename _Result,
typename _Signature>
734 template<
typename _Result,
typename _Functor,
typename... _Bound_args>
737 typedef typename _Build_index_tuple<
sizeof...(_Bound_args)>::__type
741 tuple<_Bound_args...> _M_bound_args;
744 template<
typename _Res,
typename... _Args, std::size_t... _Indexes>
749 return std::__invoke_r<_Res>(_M_f, _Mu<_Bound_args>()
750 (std::get<_Indexes>(_M_bound_args), __args)...);
754 template<
typename _Res,
typename... _Args, std::size_t... _Indexes>
759 return std::__invoke_r<_Res>(_M_f, _Mu<_Bound_args>()
760 (std::get<_Indexes>(_M_bound_args), __args)...);
763#ifdef _GLIBCXX_VOLATILE_BIND
765 template<
typename _Res,
typename... _Args, std::size_t... _Indexes>
769 return std::__invoke_r<_Res>(_M_f, _Mu<_Bound_args>()
770 (__volget<_Indexes>(_M_bound_args), __args)...);
774 template<
typename _Res,
typename... _Args, std::size_t... _Indexes>
777 _Index_tuple<_Indexes...>)
const volatile
779 return std::__invoke_r<_Res>(_M_f, _Mu<_Bound_args>()
780 (__volget<_Indexes>(_M_bound_args), __args)...);
785 typedef _Result result_type;
787 template<
typename... _Args>
788 explicit _GLIBCXX20_CONSTEXPR
793 template<
typename... _Args>
794 explicit _GLIBCXX20_CONSTEXPR
803 template<
typename... _Args>
806 operator()(_Args&&... __args)
808 return this->__call<_Result>(
814 template<
typename... _Args>
817 operator()(_Args&&... __args)
const
819 return this->__call<_Result>(
824#ifdef _GLIBCXX_VOLATILE_BIND
826 template<
typename... _Args>
829 operator()(_Args&&... __args)
volatile
831 return this->__call<_Result>(
837 template<
typename... _Args>
840 operator()(_Args&&... __args)
const volatile
842 return this->__call<_Result>(
847 template<
typename... _Args>
848 void operator()(_Args&&...)
const volatile =
delete;
852#undef _GLIBCXX_VOLATILE_BIND
853#undef _GLIBCXX_DEPR_BIND
859 template<
typename _Signature>
867 template<
typename _Signature>
875 template<
typename _Signature>
883 template<
typename _Signature>
891 template<
typename _Result,
typename _Signature>
899 template<
typename _Result,
typename _Signature>
907 template<
typename _Result,
typename _Signature>
915 template<
typename _Result,
typename _Signature>
919 template<
typename _Func,
typename... _BoundArgs>
920 struct _Bind_check_arity { };
922 template<
typename _Ret,
typename... _Args,
typename... _BoundArgs>
923 struct _Bind_check_arity<_Ret (*)(_Args...), _BoundArgs...>
925 static_assert(
sizeof...(_BoundArgs) ==
sizeof...(_Args),
926 "Wrong number of arguments for function");
929 template<
typename _Ret,
typename... _Args,
typename... _BoundArgs>
930 struct _Bind_check_arity<_Ret (*)(_Args..., ...), _BoundArgs...>
932 static_assert(
sizeof...(_BoundArgs) >=
sizeof...(_Args),
933 "Wrong number of arguments for function");
936 template<
typename _Tp,
typename _Class,
typename... _BoundArgs>
937 struct _Bind_check_arity<_Tp _Class::*, _BoundArgs...>
939 using _Arity =
typename _Mem_fn<_Tp _Class::*>::_Arity;
940 using _Varargs =
typename _Mem_fn<_Tp _Class::*>::_Varargs;
941 static_assert(_Varargs::value
942 ?
sizeof...(_BoundArgs) >= _Arity::value + 1
943 :
sizeof...(_BoundArgs) == _Arity::value + 1,
944 "Wrong number of arguments for pointer-to-member");
950 template<typename _Tp, typename _Tp2 = typename decay<_Tp>::type>
951 using __is_socketlike = __or_<is_integral<_Tp2>,
is_enum<_Tp2>>;
953 template<
bool _SocketLike,
typename _Func,
typename... _BoundArgs>
955 : _Bind_check_arity<typename decay<_Func>::type, _BoundArgs...>
957 typedef typename decay<_Func>::type __func_type;
958 typedef _Bind<__func_type(
typename decay<_BoundArgs>::type...)> type;
964 template<
typename _Func,
typename... _BoundArgs>
965 struct _Bind_helper<true, _Func, _BoundArgs...>
973 template<
typename _Func,
typename... _BoundArgs>
974 inline _GLIBCXX20_CONSTEXPR
typename
975 _Bind_helper<__is_socketlike<_Func>::value, _Func, _BoundArgs...>::type
976 bind(_Func&& __f, _BoundArgs&&... __args)
978 typedef _Bind_helper<
false, _Func, _BoundArgs...> __helper_type;
983 template<
typename _Result,
typename _Func,
typename... _BoundArgs>
984 struct _Bindres_helper
985 : _Bind_check_arity<typename decay<_Func>::type, _BoundArgs...>
987 typedef typename decay<_Func>::type __functor_type;
988 typedef _Bind_result<_Result,
989 __functor_type(
typename decay<_BoundArgs>::type...)>
998 template<
typename _Result,
typename _Func,
typename... _BoundArgs>
999 inline _GLIBCXX20_CONSTEXPR
1000 typename _Bindres_helper<_Result, _Func, _BoundArgs...>::type
1001 bind(_Func&& __f, _BoundArgs&&... __args)
1003 typedef _Bindres_helper<_Result, _Func, _BoundArgs...> __helper_type;
1008#if __cpp_lib_bind_front >= 202306L || __cpp_lib_bind_back >= 202306L
1009 template <auto __fn>
1012 using _Fn =
const decltype(__fn)&;
1013 template <
typename... _Args>
1014 requires is_invocable_v<_Fn, _Args...>
1015 constexpr static decltype(
auto)
1016 operator()(_Args&&... __args)
1017 noexcept(is_nothrow_invocable_v<_Fn, _Args...>)
1022#ifdef __cpp_lib_bind_front
1032 template<
typename _Fn,
typename... _Args>
1033 constexpr _Bind_front_t<_Fn, _Args...>
1034 bind_front(_Fn&& __fn, _Args&&... __args)
1035 noexcept(is_nothrow_constructible_v<_Bind_front_t<_Fn, _Args...>,
1036 int, _Fn, _Args...>)
1042#if __cpp_lib_bind_front >= 202306L
1052 template<
auto __fn,
typename... _BindArgs>
1053 constexpr decltype(
auto)
1054 bind_front(_BindArgs&&... __bind_args)
1055 noexcept(__and_v<is_nothrow_constructible<_BindArgs>...>)
1057 using _Fn =
decltype(__fn);
1058 if constexpr (is_pointer_v<_Fn> || is_member_pointer_v<_Fn>)
1059 static_assert(__fn !=
nullptr);
1061 if constexpr (
sizeof...(_BindArgs) == 0)
1062 return _Bind_fn_t<__fn>{};
1064 return _Bind_front_t<_Bind_fn_t<__fn>, _BindArgs...>(0,
1071#ifdef __cpp_lib_bind_back
1081 template<
typename _Fn,
typename... _Args>
1082 constexpr _Bind_back_t<_Fn, _Args...>
1083 bind_back(_Fn&& __fn, _Args&&... __args)
1084 noexcept(is_nothrow_constructible_v<_Bind_back_t<_Fn, _Args...>,
1085 int, _Fn, _Args...>)
1091#if __cpp_lib_bind_back >= 202306L
1102 template<
auto __fn,
typename... _BindArgs>
1103 constexpr decltype(
auto)
1104 bind_back(_BindArgs&&... __bind_args)
1105 noexcept(__and_v<is_nothrow_constructible<_BindArgs>...>)
1107 using _Fn =
decltype(__fn);
1108 if constexpr (is_pointer_v<_Fn> || is_member_pointer_v<_Fn>)
1109 static_assert(__fn !=
nullptr);
1111 if constexpr (
sizeof...(_BindArgs) == 0)
1112 return _Bind_fn_t<__fn>{};
1114 return _Bind_back_t<_Bind_fn_t<__fn>, _BindArgs...>(0,
1120#if __cplusplus >= 201402L
1122 template<
typename _Fn>
1125 template<
typename _Fn2,
typename... _Args>
1126 using __inv_res_t =
typename __invoke_result<_Fn2, _Args...>
::type;
1128 template<
typename _Tp>
1133 template<
typename _Fn2>
1135 _Not_fn(_Fn2&& __fn,
int)
1138 _Not_fn(
const _Not_fn& __fn) =
default;
1139 _Not_fn(_Not_fn&& __fn) =
default;
1140 ~_Not_fn() =
default;
1142#if _GLIBCXX_EXPLICIT_THIS_PARAMETER
1143# pragma GCC diagnostic push
1144# pragma GCC diagnostic ignored "-Wc++23-extensions"
1145 template<
typename _Self,
typename... _Args>
1146 _GLIBCXX20_CONSTEXPR
1147 decltype(_S_not<__inv_res_t<__like_t<_Self, _Fn>, _Args...>>())
1148 operator()(
this _Self&& __self, _Args&&... __args)
1149 noexcept(__is_nothrow_invocable<__like_t<_Self, _Fn>, _Args...>::value
1150 &&
noexcept(_S_not<__inv_res_t<__like_t<_Self, _Fn>, _Args...>>()))
1152 return !
std::__invoke(__like_t<_Self, _Not_fn>(__self)._M_fn,
1155# pragma GCC diagnostic pop
1160#define _GLIBCXX_NOT_FN_CALL_OP( _QUALS ) \
1161 template<typename... _Args, \
1162 typename = enable_if_t<__is_invocable<_Fn _QUALS, _Args...>::value>> \
1163 _GLIBCXX20_CONSTEXPR \
1164 decltype(_S_not<__inv_res_t<_Fn _QUALS, _Args...>>()) \
1165 operator()(_Args&&... __args) _QUALS \
1166 noexcept(__is_nothrow_invocable<_Fn _QUALS, _Args...>::value \
1167 && noexcept(_S_not<__inv_res_t<_Fn _QUALS, _Args...>>())) \
1169 return !std::__invoke(std::forward< _Fn _QUALS >(_M_fn), \
1170 std::forward<_Args>(__args)...); \
1173 template<typename... _Args, \
1174 typename = enable_if_t<!__is_invocable<_Fn _QUALS, _Args...>::value>> \
1175 void operator()(_Args&&... __args) _QUALS = delete;
1177 _GLIBCXX_NOT_FN_CALL_OP( & )
1178 _GLIBCXX_NOT_FN_CALL_OP(
const & )
1179 _GLIBCXX_NOT_FN_CALL_OP( && )
1180 _GLIBCXX_NOT_FN_CALL_OP(
const && )
1181#undef _GLIBCXX_NOT_FN_CALL_OP
1188 template<
typename _Tp,
typename _Pred>
1191 template<
typename _Tp>
1192 struct __is_byte_like<_Tp, equal_to<_Tp>>
1193 : __bool_constant<sizeof(_Tp) == 1 && is_integral<_Tp>::value> { };
1195 template<
typename _Tp>
1196 struct __is_byte_like<_Tp,
equal_to<void>>
1197 : __bool_constant<sizeof(_Tp) == 1 && is_integral<_Tp>::value> { };
1199#if __cplusplus >= 201703L
1201 enum class byte :
unsigned char;
1204 struct __is_byte_like<byte,
equal_to<byte>>
1208 struct __is_byte_like<byte,
equal_to<void>>
1213#ifdef __cpp_lib_not_fn
1226 template<
typename _Fn>
1227 _GLIBCXX20_CONSTEXPR
1230 noexcept(std::is_nothrow_constructible<std::decay_t<_Fn>, _Fn&&>::value)
1235#if __cpp_lib_not_fn >= 202306L
1249 constexpr decltype(
auto)
1252 using _Fn =
decltype(__fn);
1253 if constexpr (is_pointer_v<_Fn> || is_member_pointer_v<_Fn>)
1254 static_assert(__fn !=
nullptr);
1255 return []<
typename... _Args>(_Args&&... __args)
static
1266#if __cplusplus >= 201703L
1269 template<
typename _ForwardIterator1,
typename _BinaryPredicate = equal_to<>>
1270 class default_searcher
1273 _GLIBCXX20_CONSTEXPR
1274 default_searcher(_ForwardIterator1 __pat_first,
1275 _ForwardIterator1 __pat_last,
1276 _BinaryPredicate __pred = _BinaryPredicate())
1277 : _M_m(__pat_first, __pat_last, std::
move(__pred))
1280 template<
typename _ForwardIterator2>
1281 _GLIBCXX20_CONSTEXPR
1283 operator()(_ForwardIterator2 __first, _ForwardIterator2 __last)
const
1285 _ForwardIterator2 __first_ret =
1286 std::search(__first, __last, std::get<0>(_M_m), std::get<1>(_M_m),
1289 if (__ret.first != __last)
1291 std::get<1>(_M_m)));
1296 tuple<_ForwardIterator1, _ForwardIterator1, _BinaryPredicate> _M_m;
1299#ifdef __cpp_lib_boyer_moore_searcher
1301 template<
typename _Key,
typename _Tp,
typename _Hash,
typename _Pred>
1302 struct __boyer_moore_map_base
1304 template<
typename _RAIter>
1305 __boyer_moore_map_base(_RAIter __pat,
size_t __patlen,
1306 _Hash&& __hf, _Pred&& __pred)
1307 : _M_bad_char{ __patlen, std::move(__hf), std::move(__pred) }
1310 for (__diff_type __i = 0; __i < __patlen - 1; ++__i)
1311 _M_bad_char[__pat[__i]] = __patlen - 1 - __i;
1314 using __diff_type = _Tp;
1317 _M_lookup(_Key __key, __diff_type __not_found)
const
1319 auto __iter = _M_bad_char.find(__key);
1320 if (__iter == _M_bad_char.end())
1322 return __iter->second;
1326 _M_pred()
const {
return _M_bad_char.key_eq(); }
1328 _GLIBCXX_STD_C::unordered_map<_Key, _Tp, _Hash, _Pred> _M_bad_char;
1331 template<
typename _Tp,
size_t _Len,
typename _Pred>
1332 struct __boyer_moore_array_base
1334 template<
typename _RAIter,
typename _Unused>
1335 __boyer_moore_array_base(_RAIter __pat,
size_t __patlen,
1336 _Unused&&, _Pred&& __pred)
1337 : _M_bad_char{ array<_Tp, _Len>{},
std::move(__pred) }
1339 std::get<0>(_M_bad_char).fill(__patlen);
1341 for (__diff_type __i = 0; __i < __patlen - 1; ++__i)
1343 auto __ch = __pat[__i];
1345 auto __uch =
static_cast<_UCh
>(__ch);
1346 std::get<0>(_M_bad_char)[__uch] = __patlen - 1 - __i;
1350 using __diff_type = _Tp;
1352 template<
typename _Key>
1354 _M_lookup(_Key __key, __diff_type __not_found)
const
1359 return std::get<0>(_M_bad_char)[__ukey];
1363 _M_pred()
const {
return std::get<1>(_M_bad_char); }
1370 template<
typename _RAIter,
typename _Hash,
typename _Pred,
1371 typename _Val =
typename iterator_traits<_RAIter>::value_type,
1372 typename _Diff =
typename iterator_traits<_RAIter>::difference_type>
1373 using __boyer_moore_base_t
1374 = __conditional_t<__is_byte_like<_Val, _Pred>::value,
1375 __boyer_moore_array_base<_Diff, 256, _Pred>,
1376 __boyer_moore_map_base<_Val, _Diff, _Hash, _Pred>>;
1378 template<
typename _RAIter,
typename _Hash
1379 = hash<typename iterator_traits<_RAIter>::value_type>,
1380 typename _BinaryPredicate = equal_to<>>
1381 class boyer_moore_searcher
1382 : __boyer_moore_base_t<_RAIter, _Hash, _BinaryPredicate>
1384 using _Base = __boyer_moore_base_t<_RAIter, _Hash, _BinaryPredicate>;
1385 using typename _Base::__diff_type;
1388 boyer_moore_searcher(_RAIter __pat_first, _RAIter __pat_last,
1389 _Hash __hf = _Hash(),
1390 _BinaryPredicate __pred = _BinaryPredicate());
1392 template<
typename _RandomAccessIterator2>
1393 pair<_RandomAccessIterator2, _RandomAccessIterator2>
1394 operator()(_RandomAccessIterator2 __first,
1395 _RandomAccessIterator2 __last)
const;
1399 _M_is_prefix(_RAIter __word, __diff_type __len,
1402 const auto& __pred = this->_M_pred();
1403 __diff_type __suffixlen = __len - __pos;
1404 for (__diff_type __i = 0; __i < __suffixlen; ++__i)
1405 if (!__pred(__word[__i], __word[__pos + __i]))
1411 _M_suffix_length(_RAIter __word, __diff_type __len,
1414 const auto& __pred = this->_M_pred();
1415 __diff_type __i = 0;
1416 while (__pred(__word[__pos - __i], __word[__len - 1 - __i])
1424 template<
typename _Tp>
1426 _M_bad_char_shift(_Tp __c)
const
1427 {
return this->_M_lookup(__c, _M_pat_end - _M_pat); }
1431 _GLIBCXX_STD_C::vector<__diff_type> _M_good_suffix;
1434 template<
typename _RAIter,
typename _Hash
1435 = hash<typename iterator_traits<_RAIter>::value_type>,
1436 typename _BinaryPredicate = equal_to<>>
1437 class boyer_moore_horspool_searcher
1438 : __boyer_moore_base_t<_RAIter, _Hash, _BinaryPredicate>
1440 using _Base = __boyer_moore_base_t<_RAIter, _Hash, _BinaryPredicate>;
1441 using typename _Base::__diff_type;
1444 boyer_moore_horspool_searcher(_RAIter __pat,
1446 _Hash __hf = _Hash(),
1447 _BinaryPredicate __pred
1448 = _BinaryPredicate())
1449 : _Base(__pat, __pat_end - __pat, std::move(__hf), std::move(__pred)),
1450 _M_pat(__pat), _M_pat_end(__pat_end)
1453 template<
typename _RandomAccessIterator2>
1454 pair<_RandomAccessIterator2, _RandomAccessIterator2>
1455 operator()(_RandomAccessIterator2 __first,
1456 _RandomAccessIterator2 __last)
const
1458#ifdef __glibcxx_concepts
1461 static_assert(is_same_v<iter_value_t<_RAIter>,
1462 iter_value_t<_RandomAccessIterator2>>);
1464 const auto& __pred = this->_M_pred();
1465 auto __patlen = _M_pat_end - _M_pat;
1468 auto __len = __last - __first;
1469 while (__len >= __patlen)
1471 for (
auto __scan = __patlen - 1;
1472 __pred(__first[__scan], _M_pat[__scan]); --__scan)
1475 auto __shift = _M_bad_char_shift(__first[__patlen - 1]);
1483 template<
typename _Tp>
1485 _M_bad_char_shift(_Tp __c)
const
1486 {
return this->_M_lookup(__c, _M_pat_end - _M_pat); }
1492 template<
typename _RAIter,
typename _Hash,
typename _BinaryPredicate>
1493 boyer_moore_searcher<_RAIter, _Hash, _BinaryPredicate>::
1494 boyer_moore_searcher(_RAIter __pat, _RAIter __pat_end,
1495 _Hash __hf, _BinaryPredicate __pred)
1496 : _Base(__pat, __pat_end - __pat,
std::move(__hf),
std::move(__pred)),
1497 _M_pat(__pat), _M_pat_end(__pat_end), _M_good_suffix(__pat_end - __pat)
1499 auto __patlen = __pat_end - __pat;
1502 __diff_type __last_prefix = __patlen - 1;
1503 for (__diff_type __p = __patlen - 1; __p >= 0; --__p)
1505 if (_M_is_prefix(__pat, __patlen, __p + 1))
1506 __last_prefix = __p + 1;
1507 _M_good_suffix[__p] = __last_prefix + (__patlen - 1 - __p);
1509 for (__diff_type __p = 0; __p < __patlen - 1; ++__p)
1511 auto __slen = _M_suffix_length(__pat, __patlen, __p);
1512 auto __pos = __patlen - 1 - __slen;
1513 if (!__pred(__pat[__p - __slen], __pat[__pos]))
1514 _M_good_suffix[__pos] = __patlen - 1 - __p + __slen;
1518 template<
typename _RAIter,
typename _Hash,
typename _BinaryPredicate>
1519 template<
typename _RandomAccessIterator2>
1521 boyer_moore_searcher<_RAIter, _Hash, _BinaryPredicate>::
1522 operator()(_RandomAccessIterator2 __first,
1523 _RandomAccessIterator2 __last)
const
1525#ifdef __glibcxx_concepts
1528 static_assert(is_same_v<iter_value_t<_RAIter>,
1529 iter_value_t<_RandomAccessIterator2>>);
1531 auto __patlen = _M_pat_end - _M_pat;
1534 const auto& __pred = this->_M_pred();
1535 __diff_type __i = __patlen - 1;
1536 auto __stringlen = __last - __first;
1537 while (__i < __stringlen)
1539 __diff_type __j = __patlen - 1;
1540 while (__j >= 0 && __pred(__first[__i], _M_pat[__j]))
1547 const auto __match = __first + __diff_type(__i + 1);
1550 __i +=
std::max(_M_bad_char_shift(__first[__i]),
1551 _M_good_suffix[__j]);
1561_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.