56 #ifndef _STL_FUNCTION_H
57 #define _STL_FUNCTION_H 1
59 #if __cplusplus > 201103L
63 namespace std _GLIBCXX_VISIBILITY(default)
65 _GLIBCXX_BEGIN_NAMESPACE_VERSION
104 template<
typename _Arg,
typename _Result>
117 template<
typename _Arg1,
typename _Arg2,
typename _Result>
143 #if __cplusplus > 201103L
144 struct __is_transparent;
146 template<
typename _Tp =
void>
149 template<
typename _Tp =
void>
152 template<
typename _Tp =
void>
155 template<
typename _Tp =
void>
158 template<
typename _Tp =
void>
161 template<
typename _Tp =
void>
166 template<
typename _Tp>
171 operator()(
const _Tp& __x,
const _Tp& __y)
const
172 {
return __x + __y; }
176 template<
typename _Tp>
177 struct minus :
public binary_function<_Tp, _Tp, _Tp>
181 operator()(
const _Tp& __x,
const _Tp& __y)
const
182 {
return __x - __y; }
186 template<
typename _Tp>
187 struct multiplies :
public binary_function<_Tp, _Tp, _Tp>
191 operator()(
const _Tp& __x,
const _Tp& __y)
const
192 {
return __x * __y; }
196 template<
typename _Tp>
197 struct divides :
public binary_function<_Tp, _Tp, _Tp>
201 operator()(
const _Tp& __x,
const _Tp& __y)
const
202 {
return __x / __y; }
206 template<
typename _Tp>
207 struct modulus :
public binary_function<_Tp, _Tp, _Tp>
211 operator()(
const _Tp& __x,
const _Tp& __y)
const
212 {
return __x % __y; }
216 template<
typename _Tp>
217 struct negate :
public unary_function<_Tp, _Tp>
221 operator()(
const _Tp& __x)
const
225 #if __cplusplus > 201103L
227 #define __cpp_lib_transparent_operators 201510
232 template <
typename _Tp,
typename _Up>
235 operator()(_Tp&& __t, _Up&& __u)
const
236 noexcept(noexcept(std::forward<_Tp>(__t) + std::forward<_Up>(__u)))
237 -> decltype(std::forward<_Tp>(__t) + std::forward<_Up>(__u))
238 {
return std::forward<_Tp>(__t) + std::forward<_Up>(__u); }
240 typedef __is_transparent is_transparent;
247 template <
typename _Tp,
typename _Up>
250 operator()(_Tp&& __t, _Up&& __u)
const
251 noexcept(noexcept(std::forward<_Tp>(__t) - std::forward<_Up>(__u)))
252 -> decltype(std::forward<_Tp>(__t) - std::forward<_Up>(__u))
253 {
return std::forward<_Tp>(__t) - std::forward<_Up>(__u); }
255 typedef __is_transparent is_transparent;
262 template <
typename _Tp,
typename _Up>
265 operator()(_Tp&& __t, _Up&& __u)
const
266 noexcept(noexcept(std::forward<_Tp>(__t) * std::forward<_Up>(__u)))
267 -> decltype(std::forward<_Tp>(__t) * std::forward<_Up>(__u))
268 {
return std::forward<_Tp>(__t) * std::forward<_Up>(__u); }
270 typedef __is_transparent is_transparent;
277 template <
typename _Tp,
typename _Up>
280 operator()(_Tp&& __t, _Up&& __u)
const
281 noexcept(noexcept(std::forward<_Tp>(__t) / std::forward<_Up>(__u)))
282 -> decltype(std::forward<_Tp>(__t) / std::forward<_Up>(__u))
283 {
return std::forward<_Tp>(__t) / std::forward<_Up>(__u); }
285 typedef __is_transparent is_transparent;
292 template <
typename _Tp,
typename _Up>
295 operator()(_Tp&& __t, _Up&& __u)
const
296 noexcept(noexcept(std::forward<_Tp>(__t) % std::forward<_Up>(__u)))
297 -> decltype(std::forward<_Tp>(__t) % std::forward<_Up>(__u))
298 {
return std::forward<_Tp>(__t) % std::forward<_Up>(__u); }
300 typedef __is_transparent is_transparent;
307 template <
typename _Tp>
310 operator()(_Tp&& __t)
const
311 noexcept(noexcept(-std::forward<_Tp>(__t)))
312 -> decltype(-std::forward<_Tp>(__t))
313 {
return -std::forward<_Tp>(__t); }
315 typedef __is_transparent is_transparent;
329 #if __cplusplus > 201103L
330 template<
typename _Tp =
void>
333 template<
typename _Tp =
void>
336 template<
typename _Tp =
void>
339 template<
typename _Tp =
void>
342 template<
typename _Tp =
void>
345 template<
typename _Tp =
void>
350 template<
typename _Tp>
355 operator()(
const _Tp& __x,
const _Tp& __y)
const
356 {
return __x == __y; }
360 template<
typename _Tp>
361 struct not_equal_to :
public binary_function<_Tp, _Tp, bool>
365 operator()(
const _Tp& __x,
const _Tp& __y)
const
366 {
return __x != __y; }
370 template<
typename _Tp>
371 struct greater :
public binary_function<_Tp, _Tp, bool>
375 operator()(
const _Tp& __x,
const _Tp& __y)
const
376 {
return __x > __y; }
380 template<
typename _Tp>
381 struct less :
public binary_function<_Tp, _Tp, bool>
385 operator()(
const _Tp& __x,
const _Tp& __y)
const
386 {
return __x < __y; }
390 template<
typename _Tp>
391 struct greater_equal :
public binary_function<_Tp, _Tp, bool>
395 operator()(
const _Tp& __x,
const _Tp& __y)
const
396 {
return __x >= __y; }
400 template<
typename _Tp>
401 struct less_equal :
public binary_function<_Tp, _Tp, bool>
405 operator()(
const _Tp& __x,
const _Tp& __y)
const
406 {
return __x <= __y; }
409 #if __cplusplus > 201103L
414 template <
typename _Tp,
typename _Up>
417 operator()(_Tp&& __t, _Up&& __u)
const
418 noexcept(noexcept(std::forward<_Tp>(__t) == std::forward<_Up>(__u)))
419 -> decltype(std::forward<_Tp>(__t) == std::forward<_Up>(__u))
420 {
return std::forward<_Tp>(__t) == std::forward<_Up>(__u); }
422 typedef __is_transparent is_transparent;
429 template <
typename _Tp,
typename _Up>
432 operator()(_Tp&& __t, _Up&& __u)
const
433 noexcept(noexcept(std::forward<_Tp>(__t) != std::forward<_Up>(__u)))
434 -> decltype(std::forward<_Tp>(__t) != std::forward<_Up>(__u))
435 {
return std::forward<_Tp>(__t) != std::forward<_Up>(__u); }
437 typedef __is_transparent is_transparent;
444 template <
typename _Tp,
typename _Up>
447 operator()(_Tp&& __t, _Up&& __u)
const
448 noexcept(noexcept(std::forward<_Tp>(__t) > std::forward<_Up>(__u)))
449 -> decltype(std::forward<_Tp>(__t) > std::forward<_Up>(__u))
450 {
return std::forward<_Tp>(__t) > std::forward<_Up>(__u); }
452 typedef __is_transparent is_transparent;
459 template <
typename _Tp,
typename _Up>
462 operator()(_Tp&& __t, _Up&& __u)
const
463 noexcept(noexcept(std::forward<_Tp>(__t) < std::forward<_Up>(__u)))
464 -> decltype(std::forward<_Tp>(__t) < std::forward<_Up>(__u))
465 {
return std::forward<_Tp>(__t) < std::forward<_Up>(__u); }
467 typedef __is_transparent is_transparent;
474 template <
typename _Tp,
typename _Up>
477 operator()(_Tp&& __t, _Up&& __u)
const
478 noexcept(noexcept(std::forward<_Tp>(__t) >= std::forward<_Up>(__u)))
479 -> decltype(std::forward<_Tp>(__t) >= std::forward<_Up>(__u))
480 {
return std::forward<_Tp>(__t) >= std::forward<_Up>(__u); }
482 typedef __is_transparent is_transparent;
489 template <
typename _Tp,
typename _Up>
492 operator()(_Tp&& __t, _Up&& __u)
const
493 noexcept(noexcept(std::forward<_Tp>(__t) <= std::forward<_Up>(__u)))
494 -> decltype(std::forward<_Tp>(__t) <= std::forward<_Up>(__u))
495 {
return std::forward<_Tp>(__t) <= std::forward<_Up>(__u); }
497 typedef __is_transparent is_transparent;
511 #if __cplusplus > 201103L
512 template<
typename _Tp =
void>
515 template<
typename _Tp =
void>
518 template<
typename _Tp =
void>
523 template<
typename _Tp>
528 operator()(
const _Tp& __x,
const _Tp& __y)
const
529 {
return __x && __y; }
533 template<
typename _Tp>
534 struct logical_or :
public binary_function<_Tp, _Tp, bool>
538 operator()(
const _Tp& __x,
const _Tp& __y)
const
539 {
return __x || __y; }
543 template<
typename _Tp>
544 struct logical_not :
public unary_function<_Tp, bool>
548 operator()(
const _Tp& __x)
const
552 #if __cplusplus > 201103L
557 template <
typename _Tp,
typename _Up>
560 operator()(_Tp&& __t, _Up&& __u)
const
561 noexcept(noexcept(std::forward<_Tp>(__t) && std::forward<_Up>(__u)))
562 -> decltype(std::forward<_Tp>(__t) && std::forward<_Up>(__u))
563 {
return std::forward<_Tp>(__t) && std::forward<_Up>(__u); }
565 typedef __is_transparent is_transparent;
572 template <
typename _Tp,
typename _Up>
575 operator()(_Tp&& __t, _Up&& __u)
const
576 noexcept(noexcept(std::forward<_Tp>(__t) || std::forward<_Up>(__u)))
577 -> decltype(std::forward<_Tp>(__t) || std::forward<_Up>(__u))
578 {
return std::forward<_Tp>(__t) || std::forward<_Up>(__u); }
580 typedef __is_transparent is_transparent;
587 template <
typename _Tp>
590 operator()(_Tp&& __t)
const
591 noexcept(noexcept(!std::forward<_Tp>(__t)))
592 -> decltype(!std::forward<_Tp>(__t))
593 {
return !std::forward<_Tp>(__t); }
595 typedef __is_transparent is_transparent;
600 #if __cplusplus > 201103L
601 template<
typename _Tp =
void>
604 template<
typename _Tp =
void>
607 template<
typename _Tp =
void>
610 template<
typename _Tp =
void>
616 template<
typename _Tp>
621 operator()(
const _Tp& __x,
const _Tp& __y)
const
622 {
return __x & __y; }
625 template<
typename _Tp>
626 struct bit_or :
public binary_function<_Tp, _Tp, _Tp>
630 operator()(
const _Tp& __x,
const _Tp& __y)
const
631 {
return __x | __y; }
634 template<
typename _Tp>
635 struct bit_xor :
public binary_function<_Tp, _Tp, _Tp>
639 operator()(
const _Tp& __x,
const _Tp& __y)
const
640 {
return __x ^ __y; }
643 template<
typename _Tp>
644 struct bit_not :
public unary_function<_Tp, _Tp>
648 operator()(
const _Tp& __x)
const
652 #if __cplusplus > 201103L
656 template <
typename _Tp,
typename _Up>
659 operator()(_Tp&& __t, _Up&& __u)
const
660 noexcept(noexcept(std::forward<_Tp>(__t) & std::forward<_Up>(__u)))
661 -> decltype(std::forward<_Tp>(__t) & std::forward<_Up>(__u))
662 {
return std::forward<_Tp>(__t) & std::forward<_Up>(__u); }
664 typedef __is_transparent is_transparent;
670 template <
typename _Tp,
typename _Up>
673 operator()(_Tp&& __t, _Up&& __u)
const
674 noexcept(noexcept(std::forward<_Tp>(__t) | std::forward<_Up>(__u)))
675 -> decltype(std::forward<_Tp>(__t) | std::forward<_Up>(__u))
676 {
return std::forward<_Tp>(__t) | std::forward<_Up>(__u); }
678 typedef __is_transparent is_transparent;
684 template <
typename _Tp,
typename _Up>
687 operator()(_Tp&& __t, _Up&& __u)
const
688 noexcept(noexcept(std::forward<_Tp>(__t) ^ std::forward<_Up>(__u)))
689 -> decltype(std::forward<_Tp>(__t) ^ std::forward<_Up>(__u))
690 {
return std::forward<_Tp>(__t) ^ std::forward<_Up>(__u); }
692 typedef __is_transparent is_transparent;
698 template <
typename _Tp>
701 operator()(_Tp&& __t)
const
702 noexcept(noexcept(~std::forward<_Tp>(__t)))
703 -> decltype(~std::forward<_Tp>(__t))
704 {
return ~
std::forward<_Tp>(__t); }
706 typedef __is_transparent is_transparent;
740 template<
typename _Predicate>
754 operator()(
const typename _Predicate::argument_type& __x)
const
755 {
return !_M_pred(__x); }
759 template<
typename _Predicate>
766 template<
typename _Predicate>
769 typename _Predicate::second_argument_type, bool>
781 operator()(
const typename _Predicate::first_argument_type& __x,
782 const typename _Predicate::second_argument_type& __y)
const
783 {
return !_M_pred(__x, __y); }
787 template<
typename _Predicate>
817 template<
typename _Arg,
typename _Result>
821 _Result (*_M_ptr)(_Arg);
831 operator()(_Arg __x)
const
832 {
return _M_ptr(__x); }
836 template<
typename _Arg,
typename _Result>
842 template<
typename _Arg1,
typename _Arg2,
typename _Result>
847 _Result (*_M_ptr)(_Arg1, _Arg2);
857 operator()(_Arg1 __x, _Arg2 __y)
const
858 {
return _M_ptr(__x, __y); }
862 template<
typename _Arg1,
typename _Arg2,
typename _Result>
868 template<
typename _Tp>
870 :
public unary_function<_Tp,_Tp>
873 operator()(_Tp& __x)
const
877 operator()(
const _Tp& __x)
const
881 template<
typename _Pair>
883 :
public unary_function<_Pair, typename _Pair::first_type>
885 typename _Pair::first_type&
886 operator()(_Pair& __x)
const
887 {
return __x.first; }
889 const typename _Pair::first_type&
890 operator()(
const _Pair& __x)
const
891 {
return __x.first; }
893 #if __cplusplus >= 201103L
894 template<
typename _Pair2>
895 typename _Pair2::first_type&
896 operator()(_Pair2& __x)
const
897 {
return __x.first; }
899 template<
typename _Pair2>
900 const typename _Pair2::first_type&
901 operator()(
const _Pair2& __x)
const
902 {
return __x.first; }
906 template<
typename _Pair>
908 :
public unary_function<_Pair, typename _Pair::second_type>
910 typename _Pair::second_type&
911 operator()(_Pair& __x)
const
912 {
return __x.second; }
914 const typename _Pair::second_type&
915 operator()(
const _Pair& __x)
const
916 {
return __x.second; }
937 template<
typename _Ret,
typename _Tp>
946 operator()(_Tp* __p)
const
947 {
return (__p->*_M_f)(); }
955 template<
typename _Ret,
typename _Tp>
964 operator()(
const _Tp* __p)
const
965 {
return (__p->*_M_f)(); }
968 _Ret (_Tp::*_M_f)()
const;
973 template<
typename _Ret,
typename _Tp>
982 operator()(_Tp& __r)
const
983 {
return (__r.*_M_f)(); }
991 template<
typename _Ret,
typename _Tp>
1000 operator()(
const _Tp& __r)
const
1001 {
return (__r.*_M_f)(); }
1004 _Ret (_Tp::*_M_f)()
const;
1009 template<
typename _Ret,
typename _Tp,
typename _Arg>
1018 operator()(_Tp* __p, _Arg __x)
const
1019 {
return (__p->*_M_f)(__x); }
1022 _Ret (_Tp::*_M_f)(_Arg);
1027 template<
typename _Ret,
typename _Tp,
typename _Arg>
1036 operator()(
const _Tp* __p, _Arg __x)
const
1037 {
return (__p->*_M_f)(__x); }
1040 _Ret (_Tp::*_M_f)(_Arg)
const;
1045 template<
typename _Ret,
typename _Tp,
typename _Arg>
1054 operator()(_Tp& __r, _Arg __x)
const
1055 {
return (__r.*_M_f)(__x); }
1058 _Ret (_Tp::*_M_f)(_Arg);
1063 template<
typename _Ret,
typename _Tp,
typename _Arg>
1072 operator()(
const _Tp& __r, _Arg __x)
const
1073 {
return (__r.*_M_f)(__x); }
1076 _Ret (_Tp::*_M_f)(_Arg)
const;
1081 template<
typename _Ret,
typename _Tp>
1083 mem_fun(_Ret (_Tp::*__f)())
1086 template<
typename _Ret,
typename _Tp>
1087 inline const_mem_fun_t<_Ret, _Tp>
1088 mem_fun(_Ret (_Tp::*__f)()
const)
1089 {
return const_mem_fun_t<_Ret, _Tp>(__f); }
1091 template<
typename _Ret,
typename _Tp>
1092 inline mem_fun_ref_t<_Ret, _Tp>
1093 mem_fun_ref(_Ret (_Tp::*__f)())
1094 {
return mem_fun_ref_t<_Ret, _Tp>(__f); }
1096 template<
typename _Ret,
typename _Tp>
1097 inline const_mem_fun_ref_t<_Ret, _Tp>
1098 mem_fun_ref(_Ret (_Tp::*__f)()
const)
1099 {
return const_mem_fun_ref_t<_Ret, _Tp>(__f); }
1101 template<
typename _Ret,
typename _Tp,
typename _Arg>
1102 inline mem_fun1_t<_Ret, _Tp, _Arg>
1103 mem_fun(_Ret (_Tp::*__f)(_Arg))
1104 {
return mem_fun1_t<_Ret, _Tp, _Arg>(__f); }
1106 template<
typename _Ret,
typename _Tp,
typename _Arg>
1107 inline const_mem_fun1_t<_Ret, _Tp, _Arg>
1108 mem_fun(_Ret (_Tp::*__f)(_Arg)
const)
1109 {
return const_mem_fun1_t<_Ret, _Tp, _Arg>(__f); }
1111 template<
typename _Ret,
typename _Tp,
typename _Arg>
1112 inline mem_fun1_ref_t<_Ret, _Tp, _Arg>
1113 mem_fun_ref(_Ret (_Tp::*__f)(_Arg))
1114 {
return mem_fun1_ref_t<_Ret, _Tp, _Arg>(__f); }
1116 template<
typename _Ret,
typename _Tp,
typename _Arg>
1117 inline const_mem_fun1_ref_t<_Ret, _Tp, _Arg>
1118 mem_fun_ref(_Ret (_Tp::*__f)(_Arg)
const)
1119 {
return const_mem_fun1_ref_t<_Ret, _Tp, _Arg>(__f); }
1123 _GLIBCXX_END_NAMESPACE_VERSION
1126 #if (__cplusplus < 201103L) || _GLIBCXX_USE_DEPRECATED