libstdc++
stl_function.h
Go to the documentation of this file.
1 // Functor implementations -*- C++ -*-
2 
3 // Copyright (C) 2001-2021 Free Software Foundation, Inc.
4 //
5 // This file is part of the GNU ISO C++ Library. This library is free
6 // software; you can redistribute it and/or modify it under the
7 // terms of the GNU General Public License as published by the
8 // Free Software Foundation; either version 3, or (at your option)
9 // any later version.
10 
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
15 
16 // Under Section 7 of GPL version 3, you are granted additional
17 // permissions described in the GCC Runtime Library Exception, version
18 // 3.1, as published by the Free Software Foundation.
19 
20 // You should have received a copy of the GNU General Public License and
21 // a copy of the GCC Runtime Library Exception along with this program;
22 // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
23 // <http://www.gnu.org/licenses/>.
24 
25 /*
26  *
27  * Copyright (c) 1994
28  * Hewlett-Packard Company
29  *
30  * Permission to use, copy, modify, distribute and sell this software
31  * and its documentation for any purpose is hereby granted without fee,
32  * provided that the above copyright notice appear in all copies and
33  * that both that copyright notice and this permission notice appear
34  * in supporting documentation. Hewlett-Packard Company makes no
35  * representations about the suitability of this software for any
36  * purpose. It is provided "as is" without express or implied warranty.
37  *
38  *
39  * Copyright (c) 1996-1998
40  * Silicon Graphics Computer Systems, Inc.
41  *
42  * Permission to use, copy, modify, distribute and sell this software
43  * and its documentation for any purpose is hereby granted without fee,
44  * provided that the above copyright notice appear in all copies and
45  * that both that copyright notice and this permission notice appear
46  * in supporting documentation. Silicon Graphics makes no
47  * representations about the suitability of this software for any
48  * purpose. It is provided "as is" without express or implied warranty.
49  */
50 
51 /** @file bits/stl_function.h
52  * This is an internal header file, included by other library headers.
53  * Do not attempt to use it directly. @headername{functional}
54  */
55 
56 #ifndef _STL_FUNCTION_H
57 #define _STL_FUNCTION_H 1
58 
59 #if __cplusplus > 201103L
60 #include <bits/move.h>
61 #endif
62 
63 namespace std _GLIBCXX_VISIBILITY(default)
64 {
65 _GLIBCXX_BEGIN_NAMESPACE_VERSION
66 
67  // 20.3.1 base classes
68  /** @defgroup functors Function Objects
69  * @ingroup utilities
70  *
71  * Function objects, or _functors_, are objects with an `operator()`
72  * defined and accessible. They can be passed as arguments to algorithm
73  * templates and used in place of a function pointer. Not only is the
74  * resulting expressiveness of the library increased, but the generated
75  * code can be more efficient than what you might write by hand. When we
76  * refer to _functors_, then, generally we include function pointers in
77  * the description as well.
78  *
79  * Often, functors are only created as temporaries passed to algorithm
80  * calls, rather than being created as named variables.
81  *
82  * Two examples taken from the standard itself follow. To perform a
83  * by-element addition of two vectors `a` and `b` containing `double`,
84  * and put the result in `a`, use
85  * \code
86  * transform (a.begin(), a.end(), b.begin(), a.begin(), plus<double>());
87  * \endcode
88  * To negate every element in `a`, use
89  * \code
90  * transform(a.begin(), a.end(), a.begin(), negate<double>());
91  * \endcode
92  * The addition and negation functions will usually be inlined directly.
93  *
94  * An _adaptable function object_ is one which provides nested typedefs
95  * `result_type` and either `argument_type` (for a unary function) or
96  * `first_argument_type` and `second_argument_type` (for a binary function).
97  * Those typedefs are used by function object adaptors such as `bind2nd`.
98  * The standard library provides two class templates, `unary_function` and
99  * `binary_function`, which define those typedefs and so can be used as
100  * base classes of adaptable function objects.
101  *
102  * Since C++11 the use of function object adaptors has been superseded by
103  * more powerful tools such as lambda expressions, `function<>`, and more
104  * powerful type deduction (using `auto` and `decltype`). The helpers for
105  * defining adaptable function objects are deprecated since C++11, and no
106  * longer part of the standard library since C++17. However, they are still
107  * defined and used by libstdc++ after C++17, as a conforming extension.
108  *
109  * @{
110  */
111 
112  /**
113  * Helper for defining adaptable unary function objects.
114  * @deprecated Deprecated in C++11, no longer in the standard since C++17.
115  */
116  template<typename _Arg, typename _Result>
118  {
119  /// @c argument_type is the type of the argument
120  typedef _Arg argument_type;
121 
122  /// @c result_type is the return type
123  typedef _Result result_type;
124  };
125 
126  /**
127  * Helper for defining adaptable binary function objects.
128  * @deprecated Deprecated in C++11, no longer in the standard since C++17.
129  */
130  template<typename _Arg1, typename _Arg2, typename _Result>
132  {
133  /// @c first_argument_type is the type of the first argument
134  typedef _Arg1 first_argument_type;
135 
136  /// @c second_argument_type is the type of the second argument
137  typedef _Arg2 second_argument_type;
138 
139  /// @c result_type is the return type
140  typedef _Result result_type;
141  };
142  /** @} */
143 
144  // 20.3.2 arithmetic
145 
146  /** @defgroup arithmetic_functors Arithmetic Function Object Classes
147  * @ingroup functors
148  *
149  * The library provides function objects for basic arithmetic operations.
150  * See the documentation for @link functors function objects @endlink
151  * for examples of their use.
152  *
153  * @{
154  */
155 
156 #if __cplusplus > 201103L
157  struct __is_transparent; // undefined
158 
159  template<typename _Tp = void>
160  struct plus;
161 
162  template<typename _Tp = void>
163  struct minus;
164 
165  template<typename _Tp = void>
166  struct multiplies;
167 
168  template<typename _Tp = void>
169  struct divides;
170 
171  template<typename _Tp = void>
172  struct modulus;
173 
174  template<typename _Tp = void>
175  struct negate;
176 #endif
177 
178  /// One of the @link arithmetic_functors math functors@endlink.
179  template<typename _Tp>
180  struct plus : public binary_function<_Tp, _Tp, _Tp>
181  {
182  /// Returns the sum
183  _GLIBCXX14_CONSTEXPR
184  _Tp
185  operator()(const _Tp& __x, const _Tp& __y) const
186  { return __x + __y; }
187  };
188 
189  /// One of the @link arithmetic_functors math functors@endlink.
190  template<typename _Tp>
191  struct minus : public binary_function<_Tp, _Tp, _Tp>
192  {
193  _GLIBCXX14_CONSTEXPR
194  _Tp
195  operator()(const _Tp& __x, const _Tp& __y) const
196  { return __x - __y; }
197  };
198 
199  /// One of the @link arithmetic_functors math functors@endlink.
200  template<typename _Tp>
201  struct multiplies : public binary_function<_Tp, _Tp, _Tp>
202  {
203  _GLIBCXX14_CONSTEXPR
204  _Tp
205  operator()(const _Tp& __x, const _Tp& __y) const
206  { return __x * __y; }
207  };
208 
209  /// One of the @link arithmetic_functors math functors@endlink.
210  template<typename _Tp>
211  struct divides : public binary_function<_Tp, _Tp, _Tp>
212  {
213  _GLIBCXX14_CONSTEXPR
214  _Tp
215  operator()(const _Tp& __x, const _Tp& __y) const
216  { return __x / __y; }
217  };
218 
219  /// One of the @link arithmetic_functors math functors@endlink.
220  template<typename _Tp>
221  struct modulus : public binary_function<_Tp, _Tp, _Tp>
222  {
223  _GLIBCXX14_CONSTEXPR
224  _Tp
225  operator()(const _Tp& __x, const _Tp& __y) const
226  { return __x % __y; }
227  };
228 
229  /// One of the @link arithmetic_functors math functors@endlink.
230  template<typename _Tp>
231  struct negate : public unary_function<_Tp, _Tp>
232  {
233  _GLIBCXX14_CONSTEXPR
234  _Tp
235  operator()(const _Tp& __x) const
236  { return -__x; }
237  };
238 
239 #if __cplusplus > 201103L
240 
241 #define __cpp_lib_transparent_operators 201510
242 
243  template<>
244  struct plus<void>
245  {
246  template <typename _Tp, typename _Up>
247  _GLIBCXX14_CONSTEXPR
248  auto
249  operator()(_Tp&& __t, _Up&& __u) const
250  noexcept(noexcept(std::forward<_Tp>(__t) + std::forward<_Up>(__u)))
251  -> decltype(std::forward<_Tp>(__t) + std::forward<_Up>(__u))
252  { return std::forward<_Tp>(__t) + std::forward<_Up>(__u); }
253 
254  typedef __is_transparent is_transparent;
255  };
256 
257  /// One of the @link arithmetic_functors math functors@endlink.
258  template<>
259  struct minus<void>
260  {
261  template <typename _Tp, typename _Up>
262  _GLIBCXX14_CONSTEXPR
263  auto
264  operator()(_Tp&& __t, _Up&& __u) const
265  noexcept(noexcept(std::forward<_Tp>(__t) - std::forward<_Up>(__u)))
266  -> decltype(std::forward<_Tp>(__t) - std::forward<_Up>(__u))
267  { return std::forward<_Tp>(__t) - std::forward<_Up>(__u); }
268 
269  typedef __is_transparent is_transparent;
270  };
271 
272  /// One of the @link arithmetic_functors math functors@endlink.
273  template<>
274  struct multiplies<void>
275  {
276  template <typename _Tp, typename _Up>
277  _GLIBCXX14_CONSTEXPR
278  auto
279  operator()(_Tp&& __t, _Up&& __u) const
280  noexcept(noexcept(std::forward<_Tp>(__t) * std::forward<_Up>(__u)))
281  -> decltype(std::forward<_Tp>(__t) * std::forward<_Up>(__u))
282  { return std::forward<_Tp>(__t) * std::forward<_Up>(__u); }
283 
284  typedef __is_transparent is_transparent;
285  };
286 
287  /// One of the @link arithmetic_functors math functors@endlink.
288  template<>
289  struct divides<void>
290  {
291  template <typename _Tp, typename _Up>
292  _GLIBCXX14_CONSTEXPR
293  auto
294  operator()(_Tp&& __t, _Up&& __u) const
295  noexcept(noexcept(std::forward<_Tp>(__t) / std::forward<_Up>(__u)))
296  -> decltype(std::forward<_Tp>(__t) / std::forward<_Up>(__u))
297  { return std::forward<_Tp>(__t) / std::forward<_Up>(__u); }
298 
299  typedef __is_transparent is_transparent;
300  };
301 
302  /// One of the @link arithmetic_functors math functors@endlink.
303  template<>
304  struct modulus<void>
305  {
306  template <typename _Tp, typename _Up>
307  _GLIBCXX14_CONSTEXPR
308  auto
309  operator()(_Tp&& __t, _Up&& __u) const
310  noexcept(noexcept(std::forward<_Tp>(__t) % std::forward<_Up>(__u)))
311  -> decltype(std::forward<_Tp>(__t) % std::forward<_Up>(__u))
312  { return std::forward<_Tp>(__t) % std::forward<_Up>(__u); }
313 
314  typedef __is_transparent is_transparent;
315  };
316 
317  /// One of the @link arithmetic_functors math functors@endlink.
318  template<>
319  struct negate<void>
320  {
321  template <typename _Tp>
322  _GLIBCXX14_CONSTEXPR
323  auto
324  operator()(_Tp&& __t) const
325  noexcept(noexcept(-std::forward<_Tp>(__t)))
326  -> decltype(-std::forward<_Tp>(__t))
327  { return -std::forward<_Tp>(__t); }
328 
329  typedef __is_transparent is_transparent;
330  };
331 #endif
332  /** @} */
333 
334  // 20.3.3 comparisons
335  /** @defgroup comparison_functors Comparison Classes
336  * @ingroup functors
337  *
338  * The library provides six wrapper functors for all the basic comparisons
339  * in C++, like @c <.
340  *
341  * @{
342  */
343 #if __cplusplus > 201103L
344  template<typename _Tp = void>
345  struct equal_to;
346 
347  template<typename _Tp = void>
348  struct not_equal_to;
349 
350  template<typename _Tp = void>
351  struct greater;
352 
353  template<typename _Tp = void>
354  struct less;
355 
356  template<typename _Tp = void>
357  struct greater_equal;
358 
359  template<typename _Tp = void>
360  struct less_equal;
361 #endif
362 
363  /// One of the @link comparison_functors comparison functors@endlink.
364  template<typename _Tp>
365  struct equal_to : public binary_function<_Tp, _Tp, bool>
366  {
367  _GLIBCXX14_CONSTEXPR
368  bool
369  operator()(const _Tp& __x, const _Tp& __y) const
370  { return __x == __y; }
371  };
372 
373  /// One of the @link comparison_functors comparison functors@endlink.
374  template<typename _Tp>
375  struct not_equal_to : public binary_function<_Tp, _Tp, bool>
376  {
377  _GLIBCXX14_CONSTEXPR
378  bool
379  operator()(const _Tp& __x, const _Tp& __y) const
380  { return __x != __y; }
381  };
382 
383  /// One of the @link comparison_functors comparison functors@endlink.
384  template<typename _Tp>
385  struct greater : public binary_function<_Tp, _Tp, bool>
386  {
387  _GLIBCXX14_CONSTEXPR
388  bool
389  operator()(const _Tp& __x, const _Tp& __y) const
390  { return __x > __y; }
391  };
392 
393  /// One of the @link comparison_functors comparison functors@endlink.
394  template<typename _Tp>
395  struct less : public binary_function<_Tp, _Tp, bool>
396  {
397  _GLIBCXX14_CONSTEXPR
398  bool
399  operator()(const _Tp& __x, const _Tp& __y) const
400  { return __x < __y; }
401  };
402 
403  /// One of the @link comparison_functors comparison functors@endlink.
404  template<typename _Tp>
405  struct greater_equal : public binary_function<_Tp, _Tp, bool>
406  {
407  _GLIBCXX14_CONSTEXPR
408  bool
409  operator()(const _Tp& __x, const _Tp& __y) const
410  { return __x >= __y; }
411  };
412 
413  /// One of the @link comparison_functors comparison functors@endlink.
414  template<typename _Tp>
415  struct less_equal : public binary_function<_Tp, _Tp, bool>
416  {
417  _GLIBCXX14_CONSTEXPR
418  bool
419  operator()(const _Tp& __x, const _Tp& __y) const
420  { return __x <= __y; }
421  };
422 
423  // Partial specialization of std::greater for pointers.
424  template<typename _Tp>
425  struct greater<_Tp*> : public binary_function<_Tp*, _Tp*, bool>
426  {
427  _GLIBCXX14_CONSTEXPR bool
428  operator()(_Tp* __x, _Tp* __y) const _GLIBCXX_NOTHROW
429  {
430 #if __cplusplus >= 201402L
431 #ifdef _GLIBCXX_HAVE_BUILTIN_IS_CONSTANT_EVALUATED
432  if (__builtin_is_constant_evaluated())
433 #else
434  if (__builtin_constant_p(__x > __y))
435 #endif
436  return __x > __y;
437 #endif
438  return (__UINTPTR_TYPE__)__x > (__UINTPTR_TYPE__)__y;
439  }
440  };
441 
442  // Partial specialization of std::less for pointers.
443  template<typename _Tp>
444  struct less<_Tp*> : public binary_function<_Tp*, _Tp*, bool>
445  {
446  _GLIBCXX14_CONSTEXPR bool
447  operator()(_Tp* __x, _Tp* __y) const _GLIBCXX_NOTHROW
448  {
449 #if __cplusplus >= 201402L
450 #ifdef _GLIBCXX_HAVE_BUILTIN_IS_CONSTANT_EVALUATED
451  if (__builtin_is_constant_evaluated())
452 #else
453  if (__builtin_constant_p(__x < __y))
454 #endif
455  return __x < __y;
456 #endif
457  return (__UINTPTR_TYPE__)__x < (__UINTPTR_TYPE__)__y;
458  }
459  };
460 
461  // Partial specialization of std::greater_equal for pointers.
462  template<typename _Tp>
463  struct greater_equal<_Tp*> : public binary_function<_Tp*, _Tp*, bool>
464  {
465  _GLIBCXX14_CONSTEXPR bool
466  operator()(_Tp* __x, _Tp* __y) const _GLIBCXX_NOTHROW
467  {
468 #if __cplusplus >= 201402L
469 #ifdef _GLIBCXX_HAVE_BUILTIN_IS_CONSTANT_EVALUATED
470  if (__builtin_is_constant_evaluated())
471 #else
472  if (__builtin_constant_p(__x >= __y))
473 #endif
474  return __x >= __y;
475 #endif
476  return (__UINTPTR_TYPE__)__x >= (__UINTPTR_TYPE__)__y;
477  }
478  };
479 
480  // Partial specialization of std::less_equal for pointers.
481  template<typename _Tp>
482  struct less_equal<_Tp*> : public binary_function<_Tp*, _Tp*, bool>
483  {
484  _GLIBCXX14_CONSTEXPR bool
485  operator()(_Tp* __x, _Tp* __y) const _GLIBCXX_NOTHROW
486  {
487 #if __cplusplus >= 201402L
488 #ifdef _GLIBCXX_HAVE_BUILTIN_IS_CONSTANT_EVALUATED
489  if (__builtin_is_constant_evaluated())
490 #else
491  if (__builtin_constant_p(__x <= __y))
492 #endif
493  return __x <= __y;
494 #endif
495  return (__UINTPTR_TYPE__)__x <= (__UINTPTR_TYPE__)__y;
496  }
497  };
498 
499 #if __cplusplus >= 201402L
500  /// One of the @link comparison_functors comparison functors@endlink.
501  template<>
502  struct equal_to<void>
503  {
504  template <typename _Tp, typename _Up>
505  constexpr auto
506  operator()(_Tp&& __t, _Up&& __u) const
507  noexcept(noexcept(std::forward<_Tp>(__t) == std::forward<_Up>(__u)))
508  -> decltype(std::forward<_Tp>(__t) == std::forward<_Up>(__u))
509  { return std::forward<_Tp>(__t) == std::forward<_Up>(__u); }
510 
511  typedef __is_transparent is_transparent;
512  };
513 
514  /// One of the @link comparison_functors comparison functors@endlink.
515  template<>
516  struct not_equal_to<void>
517  {
518  template <typename _Tp, typename _Up>
519  constexpr auto
520  operator()(_Tp&& __t, _Up&& __u) const
521  noexcept(noexcept(std::forward<_Tp>(__t) != std::forward<_Up>(__u)))
522  -> decltype(std::forward<_Tp>(__t) != std::forward<_Up>(__u))
523  { return std::forward<_Tp>(__t) != std::forward<_Up>(__u); }
524 
525  typedef __is_transparent is_transparent;
526  };
527 
528  /// One of the @link comparison_functors comparison functors@endlink.
529  template<>
530  struct greater<void>
531  {
532  template <typename _Tp, typename _Up>
533  constexpr auto
534  operator()(_Tp&& __t, _Up&& __u) const
535  noexcept(noexcept(std::forward<_Tp>(__t) > std::forward<_Up>(__u)))
536  -> decltype(std::forward<_Tp>(__t) > std::forward<_Up>(__u))
537  {
538  return _S_cmp(std::forward<_Tp>(__t), std::forward<_Up>(__u),
539  __ptr_cmp<_Tp, _Up>{});
540  }
541 
542  template<typename _Tp, typename _Up>
543  constexpr bool
544  operator()(_Tp* __t, _Up* __u) const noexcept
545  { return greater<common_type_t<_Tp*, _Up*>>{}(__t, __u); }
546 
547  typedef __is_transparent is_transparent;
548 
549  private:
550  template <typename _Tp, typename _Up>
551  static constexpr decltype(auto)
552  _S_cmp(_Tp&& __t, _Up&& __u, false_type)
553  { return std::forward<_Tp>(__t) > std::forward<_Up>(__u); }
554 
555  template <typename _Tp, typename _Up>
556  static constexpr bool
557  _S_cmp(_Tp&& __t, _Up&& __u, true_type) noexcept
558  {
560  static_cast<const volatile void*>(std::forward<_Tp>(__t)),
561  static_cast<const volatile void*>(std::forward<_Up>(__u)));
562  }
563 
564  // True if there is no viable operator> member function.
565  template<typename _Tp, typename _Up, typename = void>
566  struct __not_overloaded2 : true_type { };
567 
568  // False if we can call T.operator>(U)
569  template<typename _Tp, typename _Up>
570  struct __not_overloaded2<_Tp, _Up, __void_t<
571  decltype(std::declval<_Tp>().operator>(std::declval<_Up>()))>>
572  : false_type { };
573 
574  // True if there is no overloaded operator> for these operands.
575  template<typename _Tp, typename _Up, typename = void>
576  struct __not_overloaded : __not_overloaded2<_Tp, _Up> { };
577 
578  // False if we can call operator>(T,U)
579  template<typename _Tp, typename _Up>
580  struct __not_overloaded<_Tp, _Up, __void_t<
581  decltype(operator>(std::declval<_Tp>(), std::declval<_Up>()))>>
582  : false_type { };
583 
584  template<typename _Tp, typename _Up>
585  using __ptr_cmp = __and_<__not_overloaded<_Tp, _Up>,
588  };
589 
590  /// One of the @link comparison_functors comparison functors@endlink.
591  template<>
592  struct less<void>
593  {
594  template <typename _Tp, typename _Up>
595  constexpr auto
596  operator()(_Tp&& __t, _Up&& __u) const
597  noexcept(noexcept(std::forward<_Tp>(__t) < std::forward<_Up>(__u)))
598  -> decltype(std::forward<_Tp>(__t) < std::forward<_Up>(__u))
599  {
600  return _S_cmp(std::forward<_Tp>(__t), std::forward<_Up>(__u),
601  __ptr_cmp<_Tp, _Up>{});
602  }
603 
604  template<typename _Tp, typename _Up>
605  constexpr bool
606  operator()(_Tp* __t, _Up* __u) const noexcept
607  { return less<common_type_t<_Tp*, _Up*>>{}(__t, __u); }
608 
609  typedef __is_transparent is_transparent;
610 
611  private:
612  template <typename _Tp, typename _Up>
613  static constexpr decltype(auto)
614  _S_cmp(_Tp&& __t, _Up&& __u, false_type)
615  { return std::forward<_Tp>(__t) < std::forward<_Up>(__u); }
616 
617  template <typename _Tp, typename _Up>
618  static constexpr bool
619  _S_cmp(_Tp&& __t, _Up&& __u, true_type) noexcept
620  {
622  static_cast<const volatile void*>(std::forward<_Tp>(__t)),
623  static_cast<const volatile void*>(std::forward<_Up>(__u)));
624  }
625 
626  // True if there is no viable operator< member function.
627  template<typename _Tp, typename _Up, typename = void>
628  struct __not_overloaded2 : true_type { };
629 
630  // False if we can call T.operator<(U)
631  template<typename _Tp, typename _Up>
632  struct __not_overloaded2<_Tp, _Up, __void_t<
633  decltype(std::declval<_Tp>().operator<(std::declval<_Up>()))>>
634  : false_type { };
635 
636  // True if there is no overloaded operator< for these operands.
637  template<typename _Tp, typename _Up, typename = void>
638  struct __not_overloaded : __not_overloaded2<_Tp, _Up> { };
639 
640  // False if we can call operator<(T,U)
641  template<typename _Tp, typename _Up>
642  struct __not_overloaded<_Tp, _Up, __void_t<
643  decltype(operator<(std::declval<_Tp>(), std::declval<_Up>()))>>
644  : false_type { };
645 
646  template<typename _Tp, typename _Up>
647  using __ptr_cmp = __and_<__not_overloaded<_Tp, _Up>,
650  };
651 
652  /// One of the @link comparison_functors comparison functors@endlink.
653  template<>
654  struct greater_equal<void>
655  {
656  template <typename _Tp, typename _Up>
657  constexpr auto
658  operator()(_Tp&& __t, _Up&& __u) const
659  noexcept(noexcept(std::forward<_Tp>(__t) >= std::forward<_Up>(__u)))
660  -> decltype(std::forward<_Tp>(__t) >= std::forward<_Up>(__u))
661  {
662  return _S_cmp(std::forward<_Tp>(__t), std::forward<_Up>(__u),
663  __ptr_cmp<_Tp, _Up>{});
664  }
665 
666  template<typename _Tp, typename _Up>
667  constexpr bool
668  operator()(_Tp* __t, _Up* __u) const noexcept
669  { return greater_equal<common_type_t<_Tp*, _Up*>>{}(__t, __u); }
670 
671  typedef __is_transparent is_transparent;
672 
673  private:
674  template <typename _Tp, typename _Up>
675  static constexpr decltype(auto)
676  _S_cmp(_Tp&& __t, _Up&& __u, false_type)
677  { return std::forward<_Tp>(__t) >= std::forward<_Up>(__u); }
678 
679  template <typename _Tp, typename _Up>
680  static constexpr bool
681  _S_cmp(_Tp&& __t, _Up&& __u, true_type) noexcept
682  {
684  static_cast<const volatile void*>(std::forward<_Tp>(__t)),
685  static_cast<const volatile void*>(std::forward<_Up>(__u)));
686  }
687 
688  // True if there is no viable operator>= member function.
689  template<typename _Tp, typename _Up, typename = void>
690  struct __not_overloaded2 : true_type { };
691 
692  // False if we can call T.operator>=(U)
693  template<typename _Tp, typename _Up>
694  struct __not_overloaded2<_Tp, _Up, __void_t<
695  decltype(std::declval<_Tp>().operator>=(std::declval<_Up>()))>>
696  : false_type { };
697 
698  // True if there is no overloaded operator>= for these operands.
699  template<typename _Tp, typename _Up, typename = void>
700  struct __not_overloaded : __not_overloaded2<_Tp, _Up> { };
701 
702  // False if we can call operator>=(T,U)
703  template<typename _Tp, typename _Up>
704  struct __not_overloaded<_Tp, _Up, __void_t<
705  decltype(operator>=(std::declval<_Tp>(), std::declval<_Up>()))>>
706  : false_type { };
707 
708  template<typename _Tp, typename _Up>
709  using __ptr_cmp = __and_<__not_overloaded<_Tp, _Up>,
712  };
713 
714  /// One of the @link comparison_functors comparison functors@endlink.
715  template<>
716  struct less_equal<void>
717  {
718  template <typename _Tp, typename _Up>
719  constexpr auto
720  operator()(_Tp&& __t, _Up&& __u) const
721  noexcept(noexcept(std::forward<_Tp>(__t) <= std::forward<_Up>(__u)))
722  -> decltype(std::forward<_Tp>(__t) <= std::forward<_Up>(__u))
723  {
724  return _S_cmp(std::forward<_Tp>(__t), std::forward<_Up>(__u),
725  __ptr_cmp<_Tp, _Up>{});
726  }
727 
728  template<typename _Tp, typename _Up>
729  constexpr bool
730  operator()(_Tp* __t, _Up* __u) const noexcept
731  { return less_equal<common_type_t<_Tp*, _Up*>>{}(__t, __u); }
732 
733  typedef __is_transparent is_transparent;
734 
735  private:
736  template <typename _Tp, typename _Up>
737  static constexpr decltype(auto)
738  _S_cmp(_Tp&& __t, _Up&& __u, false_type)
739  { return std::forward<_Tp>(__t) <= std::forward<_Up>(__u); }
740 
741  template <typename _Tp, typename _Up>
742  static constexpr bool
743  _S_cmp(_Tp&& __t, _Up&& __u, true_type) noexcept
744  {
746  static_cast<const volatile void*>(std::forward<_Tp>(__t)),
747  static_cast<const volatile void*>(std::forward<_Up>(__u)));
748  }
749 
750  // True if there is no viable operator<= member function.
751  template<typename _Tp, typename _Up, typename = void>
752  struct __not_overloaded2 : true_type { };
753 
754  // False if we can call T.operator<=(U)
755  template<typename _Tp, typename _Up>
756  struct __not_overloaded2<_Tp, _Up, __void_t<
757  decltype(std::declval<_Tp>().operator<=(std::declval<_Up>()))>>
758  : false_type { };
759 
760  // True if there is no overloaded operator<= for these operands.
761  template<typename _Tp, typename _Up, typename = void>
762  struct __not_overloaded : __not_overloaded2<_Tp, _Up> { };
763 
764  // False if we can call operator<=(T,U)
765  template<typename _Tp, typename _Up>
766  struct __not_overloaded<_Tp, _Up, __void_t<
767  decltype(operator<=(std::declval<_Tp>(), std::declval<_Up>()))>>
768  : false_type { };
769 
770  template<typename _Tp, typename _Up>
771  using __ptr_cmp = __and_<__not_overloaded<_Tp, _Up>,
774  };
775 #endif // C++14
776  /** @} */
777 
778  // 20.3.4 logical operations
779  /** @defgroup logical_functors Boolean Operations Classes
780  * @ingroup functors
781  *
782  * The library provides function objects for the logical operations:
783  * `&&`, `||`, and `!`.
784  *
785  * @{
786  */
787 #if __cplusplus > 201103L
788  template<typename _Tp = void>
789  struct logical_and;
790 
791  template<typename _Tp = void>
792  struct logical_or;
793 
794  template<typename _Tp = void>
795  struct logical_not;
796 #endif
797 
798  /// One of the @link logical_functors Boolean operations functors@endlink.
799  template<typename _Tp>
800  struct logical_and : public binary_function<_Tp, _Tp, bool>
801  {
802  _GLIBCXX14_CONSTEXPR
803  bool
804  operator()(const _Tp& __x, const _Tp& __y) const
805  { return __x && __y; }
806  };
807 
808  /// One of the @link logical_functors Boolean operations functors@endlink.
809  template<typename _Tp>
810  struct logical_or : public binary_function<_Tp, _Tp, bool>
811  {
812  _GLIBCXX14_CONSTEXPR
813  bool
814  operator()(const _Tp& __x, const _Tp& __y) const
815  { return __x || __y; }
816  };
817 
818  /// One of the @link logical_functors Boolean operations functors@endlink.
819  template<typename _Tp>
820  struct logical_not : public unary_function<_Tp, bool>
821  {
822  _GLIBCXX14_CONSTEXPR
823  bool
824  operator()(const _Tp& __x) const
825  { return !__x; }
826  };
827 
828 #if __cplusplus > 201103L
829  /// One of the @link logical_functors Boolean operations functors@endlink.
830  template<>
831  struct logical_and<void>
832  {
833  template <typename _Tp, typename _Up>
834  _GLIBCXX14_CONSTEXPR
835  auto
836  operator()(_Tp&& __t, _Up&& __u) const
837  noexcept(noexcept(std::forward<_Tp>(__t) && std::forward<_Up>(__u)))
838  -> decltype(std::forward<_Tp>(__t) && std::forward<_Up>(__u))
839  { return std::forward<_Tp>(__t) && std::forward<_Up>(__u); }
840 
841  typedef __is_transparent is_transparent;
842  };
843 
844  /// One of the @link logical_functors Boolean operations functors@endlink.
845  template<>
846  struct logical_or<void>
847  {
848  template <typename _Tp, typename _Up>
849  _GLIBCXX14_CONSTEXPR
850  auto
851  operator()(_Tp&& __t, _Up&& __u) const
852  noexcept(noexcept(std::forward<_Tp>(__t) || std::forward<_Up>(__u)))
853  -> decltype(std::forward<_Tp>(__t) || std::forward<_Up>(__u))
854  { return std::forward<_Tp>(__t) || std::forward<_Up>(__u); }
855 
856  typedef __is_transparent is_transparent;
857  };
858 
859  /// One of the @link logical_functors Boolean operations functors@endlink.
860  template<>
861  struct logical_not<void>
862  {
863  template <typename _Tp>
864  _GLIBCXX14_CONSTEXPR
865  auto
866  operator()(_Tp&& __t) const
867  noexcept(noexcept(!std::forward<_Tp>(__t)))
868  -> decltype(!std::forward<_Tp>(__t))
869  { return !std::forward<_Tp>(__t); }
870 
871  typedef __is_transparent is_transparent;
872  };
873 #endif
874  /** @} */
875 
876 #if __cplusplus > 201103L
877  template<typename _Tp = void>
878  struct bit_and;
879 
880  template<typename _Tp = void>
881  struct bit_or;
882 
883  template<typename _Tp = void>
884  struct bit_xor;
885 
886  template<typename _Tp = void>
887  struct bit_not;
888 #endif
889 
890  // _GLIBCXX_RESOLVE_LIB_DEFECTS
891  // DR 660. Missing Bitwise Operations.
892  template<typename _Tp>
893  struct bit_and : public binary_function<_Tp, _Tp, _Tp>
894  {
895  _GLIBCXX14_CONSTEXPR
896  _Tp
897  operator()(const _Tp& __x, const _Tp& __y) const
898  { return __x & __y; }
899  };
900 
901  template<typename _Tp>
902  struct bit_or : public binary_function<_Tp, _Tp, _Tp>
903  {
904  _GLIBCXX14_CONSTEXPR
905  _Tp
906  operator()(const _Tp& __x, const _Tp& __y) const
907  { return __x | __y; }
908  };
909 
910  template<typename _Tp>
911  struct bit_xor : public binary_function<_Tp, _Tp, _Tp>
912  {
913  _GLIBCXX14_CONSTEXPR
914  _Tp
915  operator()(const _Tp& __x, const _Tp& __y) const
916  { return __x ^ __y; }
917  };
918 
919  template<typename _Tp>
920  struct bit_not : public unary_function<_Tp, _Tp>
921  {
922  _GLIBCXX14_CONSTEXPR
923  _Tp
924  operator()(const _Tp& __x) const
925  { return ~__x; }
926  };
927 
928 #if __cplusplus > 201103L
929  template <>
930  struct bit_and<void>
931  {
932  template <typename _Tp, typename _Up>
933  _GLIBCXX14_CONSTEXPR
934  auto
935  operator()(_Tp&& __t, _Up&& __u) const
936  noexcept(noexcept(std::forward<_Tp>(__t) & std::forward<_Up>(__u)))
937  -> decltype(std::forward<_Tp>(__t) & std::forward<_Up>(__u))
938  { return std::forward<_Tp>(__t) & std::forward<_Up>(__u); }
939 
940  typedef __is_transparent is_transparent;
941  };
942 
943  template <>
944  struct bit_or<void>
945  {
946  template <typename _Tp, typename _Up>
947  _GLIBCXX14_CONSTEXPR
948  auto
949  operator()(_Tp&& __t, _Up&& __u) const
950  noexcept(noexcept(std::forward<_Tp>(__t) | std::forward<_Up>(__u)))
951  -> decltype(std::forward<_Tp>(__t) | std::forward<_Up>(__u))
952  { return std::forward<_Tp>(__t) | std::forward<_Up>(__u); }
953 
954  typedef __is_transparent is_transparent;
955  };
956 
957  template <>
958  struct bit_xor<void>
959  {
960  template <typename _Tp, typename _Up>
961  _GLIBCXX14_CONSTEXPR
962  auto
963  operator()(_Tp&& __t, _Up&& __u) const
964  noexcept(noexcept(std::forward<_Tp>(__t) ^ std::forward<_Up>(__u)))
965  -> decltype(std::forward<_Tp>(__t) ^ std::forward<_Up>(__u))
966  { return std::forward<_Tp>(__t) ^ std::forward<_Up>(__u); }
967 
968  typedef __is_transparent is_transparent;
969  };
970 
971  template <>
972  struct bit_not<void>
973  {
974  template <typename _Tp>
975  _GLIBCXX14_CONSTEXPR
976  auto
977  operator()(_Tp&& __t) const
978  noexcept(noexcept(~std::forward<_Tp>(__t)))
979  -> decltype(~std::forward<_Tp>(__t))
980  { return ~std::forward<_Tp>(__t); }
981 
982  typedef __is_transparent is_transparent;
983  };
984 #endif
985 
986  // 20.3.5 negators
987  /** @defgroup negators Negators
988  * @ingroup functors
989  *
990  * The function templates `not1` and `not2` are function object adaptors,
991  * which each take a predicate functor and wrap it in an instance of
992  * `unary_negate` or `binary_negate`, respectively. Those classes are
993  * functors whose `operator()` evaluates the wrapped predicate function
994  * and then returns the negation of the result.
995  *
996  * For example, given a vector of integers and a trivial predicate,
997  * \code
998  * struct IntGreaterThanThree
999  * : public std::unary_function<int, bool>
1000  * {
1001  * bool operator() (int x) const { return x > 3; }
1002  * };
1003  *
1004  * std::find_if (v.begin(), v.end(), not1(IntGreaterThanThree()));
1005  * \endcode
1006  * The call to `find_if` will locate the first index (i) of `v` for which
1007  * `!(v[i] > 3)` is true.
1008  *
1009  * The not1/unary_negate combination works on predicates taking a single
1010  * argument. The not2/binary_negate combination works on predicates taking
1011  * two arguments.
1012  *
1013  * @deprecated Deprecated in C++17, no longer in the standard since C++20.
1014  * Use `not_fn` instead.
1015  *
1016  * @{
1017  */
1018  /// One of the @link negators negation functors@endlink.
1019  template<typename _Predicate>
1021  : public unary_function<typename _Predicate::argument_type, bool>
1022  {
1023  protected:
1024  _Predicate _M_pred;
1025 
1026  public:
1027  _GLIBCXX14_CONSTEXPR
1028  explicit
1029  unary_negate(const _Predicate& __x) : _M_pred(__x) { }
1030 
1031  _GLIBCXX14_CONSTEXPR
1032  bool
1033  operator()(const typename _Predicate::argument_type& __x) const
1034  { return !_M_pred(__x); }
1035  };
1036 
1037  /// One of the @link negators negation functors@endlink.
1038  template<typename _Predicate>
1039  _GLIBCXX14_CONSTEXPR
1041  not1(const _Predicate& __pred)
1042  { return unary_negate<_Predicate>(__pred); }
1043 
1044  /// One of the @link negators negation functors@endlink.
1045  template<typename _Predicate>
1047  : public binary_function<typename _Predicate::first_argument_type,
1048  typename _Predicate::second_argument_type, bool>
1049  {
1050  protected:
1051  _Predicate _M_pred;
1052 
1053  public:
1054  _GLIBCXX14_CONSTEXPR
1055  explicit
1056  binary_negate(const _Predicate& __x) : _M_pred(__x) { }
1057 
1058  _GLIBCXX14_CONSTEXPR
1059  bool
1060  operator()(const typename _Predicate::first_argument_type& __x,
1061  const typename _Predicate::second_argument_type& __y) const
1062  { return !_M_pred(__x, __y); }
1063  };
1064 
1065  /// One of the @link negators negation functors@endlink.
1066  template<typename _Predicate>
1067  _GLIBCXX14_CONSTEXPR
1069  not2(const _Predicate& __pred)
1070  { return binary_negate<_Predicate>(__pred); }
1071  /** @} */
1072 
1073  // 20.3.7 adaptors pointers functions
1074  /** @defgroup pointer_adaptors Adaptors for pointers to functions
1075  * @ingroup functors
1076  *
1077  * The advantage of function objects over pointers to functions is that
1078  * the objects in the standard library declare nested typedefs describing
1079  * their argument and result types with uniform names (e.g., `result_type`
1080  * from the base classes `unary_function` and `binary_function`).
1081  * Sometimes those typedefs are required, not just optional.
1082  *
1083  * Adaptors are provided to turn pointers to unary (single-argument) and
1084  * binary (double-argument) functions into function objects. The
1085  * long-winded functor `pointer_to_unary_function` is constructed with a
1086  * function pointer `f`, and its `operator()` called with argument `x`
1087  * returns `f(x)`. The functor `pointer_to_binary_function` does the same
1088  * thing, but with a double-argument `f` and `operator()`.
1089  *
1090  * The function `ptr_fun` takes a pointer-to-function `f` and constructs
1091  * an instance of the appropriate functor.
1092  *
1093  * @deprecated Deprecated in C++11, no longer in the standard since C++17.
1094  *
1095  * @{
1096  */
1097  /// One of the @link pointer_adaptors adaptors for function pointers@endlink.
1098  template<typename _Arg, typename _Result>
1099  class pointer_to_unary_function : public unary_function<_Arg, _Result>
1100  {
1101  protected:
1102  _Result (*_M_ptr)(_Arg);
1103 
1104  public:
1106 
1107  explicit
1108  pointer_to_unary_function(_Result (*__x)(_Arg))
1109  : _M_ptr(__x) { }
1110 
1111  _Result
1112  operator()(_Arg __x) const
1113  { return _M_ptr(__x); }
1114  };
1115 
1116  /// One of the @link pointer_adaptors adaptors for function pointers@endlink.
1117  template<typename _Arg, typename _Result>
1119  ptr_fun(_Result (*__x)(_Arg))
1121 
1122  /// One of the @link pointer_adaptors adaptors for function pointers@endlink.
1123  template<typename _Arg1, typename _Arg2, typename _Result>
1125  : public binary_function<_Arg1, _Arg2, _Result>
1126  {
1127  protected:
1128  _Result (*_M_ptr)(_Arg1, _Arg2);
1129 
1130  public:
1132 
1133  explicit
1134  pointer_to_binary_function(_Result (*__x)(_Arg1, _Arg2))
1135  : _M_ptr(__x) { }
1136 
1137  _Result
1138  operator()(_Arg1 __x, _Arg2 __y) const
1139  { return _M_ptr(__x, __y); }
1140  };
1141 
1142  /// One of the @link pointer_adaptors adaptors for function pointers@endlink.
1143  template<typename _Arg1, typename _Arg2, typename _Result>
1145  ptr_fun(_Result (*__x)(_Arg1, _Arg2))
1147  /** @} */
1148 
1149  template<typename _Tp>
1150  struct _Identity
1151  : public unary_function<_Tp, _Tp>
1152  {
1153  _Tp&
1154  operator()(_Tp& __x) const
1155  { return __x; }
1156 
1157  const _Tp&
1158  operator()(const _Tp& __x) const
1159  { return __x; }
1160  };
1161 
1162  // Partial specialization, avoids confusing errors in e.g. std::set<const T>.
1163  template<typename _Tp> struct _Identity<const _Tp> : _Identity<_Tp> { };
1164 
1165  template<typename _Pair>
1166  struct _Select1st
1167  : public unary_function<_Pair, typename _Pair::first_type>
1168  {
1169  typename _Pair::first_type&
1170  operator()(_Pair& __x) const
1171  { return __x.first; }
1172 
1173  const typename _Pair::first_type&
1174  operator()(const _Pair& __x) const
1175  { return __x.first; }
1176 
1177 #if __cplusplus >= 201103L
1178  template<typename _Pair2>
1179  typename _Pair2::first_type&
1180  operator()(_Pair2& __x) const
1181  { return __x.first; }
1182 
1183  template<typename _Pair2>
1184  const typename _Pair2::first_type&
1185  operator()(const _Pair2& __x) const
1186  { return __x.first; }
1187 #endif
1188  };
1189 
1190  template<typename _Pair>
1191  struct _Select2nd
1192  : public unary_function<_Pair, typename _Pair::second_type>
1193  {
1194  typename _Pair::second_type&
1195  operator()(_Pair& __x) const
1196  { return __x.second; }
1197 
1198  const typename _Pair::second_type&
1199  operator()(const _Pair& __x) const
1200  { return __x.second; }
1201  };
1202 
1203  // 20.3.8 adaptors pointers members
1204  /** @defgroup ptrmem_adaptors Adaptors for pointers to members
1205  * @ingroup functors
1206  *
1207  * There are a total of 8 = 2^3 function objects in this family.
1208  * (1) Member functions taking no arguments vs member functions taking
1209  * one argument.
1210  * (2) Call through pointer vs call through reference.
1211  * (3) Const vs non-const member function.
1212  *
1213  * All of this complexity is in the function objects themselves. You can
1214  * ignore it by using the helper function `mem_fun` and `mem_fun_ref`,
1215  * which create whichever type of adaptor is appropriate.
1216  *
1217  * @deprecated Deprecated in C++11, no longer in the standard since C++17.
1218  * Use `mem_fn` instead.
1219  *
1220  * @{
1221  */
1222  /// One of the @link ptrmem_adaptors adaptors for member pointers@endlink.
1223  template<typename _Ret, typename _Tp>
1224  class mem_fun_t : public unary_function<_Tp*, _Ret>
1225  {
1226  public:
1227  explicit
1228  mem_fun_t(_Ret (_Tp::*__pf)())
1229  : _M_f(__pf) { }
1230 
1231  _Ret
1232  operator()(_Tp* __p) const
1233  { return (__p->*_M_f)(); }
1234 
1235  private:
1236  _Ret (_Tp::*_M_f)();
1237  };
1238 
1239  /// One of the @link ptrmem_adaptors adaptors for member pointers@endlink.
1240  template<typename _Ret, typename _Tp>
1241  class const_mem_fun_t : public unary_function<const _Tp*, _Ret>
1242  {
1243  public:
1244  explicit
1245  const_mem_fun_t(_Ret (_Tp::*__pf)() const)
1246  : _M_f(__pf) { }
1247 
1248  _Ret
1249  operator()(const _Tp* __p) const
1250  { return (__p->*_M_f)(); }
1251 
1252  private:
1253  _Ret (_Tp::*_M_f)() const;
1254  };
1255 
1256  /// One of the @link ptrmem_adaptors adaptors for member pointers@endlink.
1257  template<typename _Ret, typename _Tp>
1258  class mem_fun_ref_t : public unary_function<_Tp, _Ret>
1259  {
1260  public:
1261  explicit
1262  mem_fun_ref_t(_Ret (_Tp::*__pf)())
1263  : _M_f(__pf) { }
1264 
1265  _Ret
1266  operator()(_Tp& __r) const
1267  { return (__r.*_M_f)(); }
1268 
1269  private:
1270  _Ret (_Tp::*_M_f)();
1271  };
1272 
1273  /// One of the @link ptrmem_adaptors adaptors for member pointers@endlink.
1274  template<typename _Ret, typename _Tp>
1275  class const_mem_fun_ref_t : public unary_function<_Tp, _Ret>
1276  {
1277  public:
1278  explicit
1279  const_mem_fun_ref_t(_Ret (_Tp::*__pf)() const)
1280  : _M_f(__pf) { }
1281 
1282  _Ret
1283  operator()(const _Tp& __r) const
1284  { return (__r.*_M_f)(); }
1285 
1286  private:
1287  _Ret (_Tp::*_M_f)() const;
1288  };
1289 
1290  /// One of the @link ptrmem_adaptors adaptors for member pointers@endlink.
1291  template<typename _Ret, typename _Tp, typename _Arg>
1292  class mem_fun1_t : public binary_function<_Tp*, _Arg, _Ret>
1293  {
1294  public:
1295  explicit
1296  mem_fun1_t(_Ret (_Tp::*__pf)(_Arg))
1297  : _M_f(__pf) { }
1298 
1299  _Ret
1300  operator()(_Tp* __p, _Arg __x) const
1301  { return (__p->*_M_f)(__x); }
1302 
1303  private:
1304  _Ret (_Tp::*_M_f)(_Arg);
1305  };
1306 
1307  /// One of the @link ptrmem_adaptors adaptors for member pointers@endlink.
1308  template<typename _Ret, typename _Tp, typename _Arg>
1309  class const_mem_fun1_t : public binary_function<const _Tp*, _Arg, _Ret>
1310  {
1311  public:
1312  explicit
1313  const_mem_fun1_t(_Ret (_Tp::*__pf)(_Arg) const)
1314  : _M_f(__pf) { }
1315 
1316  _Ret
1317  operator()(const _Tp* __p, _Arg __x) const
1318  { return (__p->*_M_f)(__x); }
1319 
1320  private:
1321  _Ret (_Tp::*_M_f)(_Arg) const;
1322  };
1323 
1324  /// One of the @link ptrmem_adaptors adaptors for member pointers@endlink.
1325  template<typename _Ret, typename _Tp, typename _Arg>
1326  class mem_fun1_ref_t : public binary_function<_Tp, _Arg, _Ret>
1327  {
1328  public:
1329  explicit
1330  mem_fun1_ref_t(_Ret (_Tp::*__pf)(_Arg))
1331  : _M_f(__pf) { }
1332 
1333  _Ret
1334  operator()(_Tp& __r, _Arg __x) const
1335  { return (__r.*_M_f)(__x); }
1336 
1337  private:
1338  _Ret (_Tp::*_M_f)(_Arg);
1339  };
1340 
1341  /// One of the @link ptrmem_adaptors adaptors for member pointers@endlink.
1342  template<typename _Ret, typename _Tp, typename _Arg>
1343  class const_mem_fun1_ref_t : public binary_function<_Tp, _Arg, _Ret>
1344  {
1345  public:
1346  explicit
1347  const_mem_fun1_ref_t(_Ret (_Tp::*__pf)(_Arg) const)
1348  : _M_f(__pf) { }
1349 
1350  _Ret
1351  operator()(const _Tp& __r, _Arg __x) const
1352  { return (__r.*_M_f)(__x); }
1353 
1354  private:
1355  _Ret (_Tp::*_M_f)(_Arg) const;
1356  };
1357 
1358  // Mem_fun adaptor helper functions. There are only two:
1359  // mem_fun and mem_fun_ref.
1360  template<typename _Ret, typename _Tp>
1361  inline mem_fun_t<_Ret, _Tp>
1362  mem_fun(_Ret (_Tp::*__f)())
1363  { return mem_fun_t<_Ret, _Tp>(__f); }
1364 
1365  template<typename _Ret, typename _Tp>
1366  inline const_mem_fun_t<_Ret, _Tp>
1367  mem_fun(_Ret (_Tp::*__f)() const)
1368  { return const_mem_fun_t<_Ret, _Tp>(__f); }
1369 
1370  template<typename _Ret, typename _Tp>
1371  inline mem_fun_ref_t<_Ret, _Tp>
1372  mem_fun_ref(_Ret (_Tp::*__f)())
1373  { return mem_fun_ref_t<_Ret, _Tp>(__f); }
1374 
1375  template<typename _Ret, typename _Tp>
1376  inline const_mem_fun_ref_t<_Ret, _Tp>
1377  mem_fun_ref(_Ret (_Tp::*__f)() const)
1378  { return const_mem_fun_ref_t<_Ret, _Tp>(__f); }
1379 
1380  template<typename _Ret, typename _Tp, typename _Arg>
1381  inline mem_fun1_t<_Ret, _Tp, _Arg>
1382  mem_fun(_Ret (_Tp::*__f)(_Arg))
1383  { return mem_fun1_t<_Ret, _Tp, _Arg>(__f); }
1384 
1385  template<typename _Ret, typename _Tp, typename _Arg>
1386  inline const_mem_fun1_t<_Ret, _Tp, _Arg>
1387  mem_fun(_Ret (_Tp::*__f)(_Arg) const)
1388  { return const_mem_fun1_t<_Ret, _Tp, _Arg>(__f); }
1389 
1390  template<typename _Ret, typename _Tp, typename _Arg>
1391  inline mem_fun1_ref_t<_Ret, _Tp, _Arg>
1392  mem_fun_ref(_Ret (_Tp::*__f)(_Arg))
1393  { return mem_fun1_ref_t<_Ret, _Tp, _Arg>(__f); }
1394 
1395  template<typename _Ret, typename _Tp, typename _Arg>
1396  inline const_mem_fun1_ref_t<_Ret, _Tp, _Arg>
1397  mem_fun_ref(_Ret (_Tp::*__f)(_Arg) const)
1398  { return const_mem_fun1_ref_t<_Ret, _Tp, _Arg>(__f); }
1399 
1400  /** @} */
1401 
1402 #if __cplusplus >= 201402L
1403  template<typename _Func, typename _SfinaeType, typename = __void_t<>>
1404  struct __has_is_transparent
1405  { };
1406 
1407  template<typename _Func, typename _SfinaeType>
1408  struct __has_is_transparent<_Func, _SfinaeType,
1409  __void_t<typename _Func::is_transparent>>
1410  { typedef void type; };
1411 
1412  template<typename _Func, typename _SfinaeType>
1413  using __has_is_transparent_t
1414  = typename __has_is_transparent<_Func, _SfinaeType>::type;
1415 #endif
1416 
1417 _GLIBCXX_END_NAMESPACE_VERSION
1418 } // namespace
1419 
1420 #if (__cplusplus < 201103L) || _GLIBCXX_USE_DEPRECATED
1421 # include <backward/binders.h>
1422 #endif
1423 
1424 #endif /* _STL_FUNCTION_H */
auto declval() noexcept -> decltype(__declval< _Tp >(0))
Definition: type_traits:2358
constexpr unary_negate< _Predicate > not1(const _Predicate &__pred)
One of the negation functors.
constexpr binary_negate< _Predicate > not2(const _Predicate &__pred)
One of the negation functors.
pointer_to_unary_function< _Arg, _Result > ptr_fun(_Result(*__x)(_Arg))
One of the adaptors for function pointers.
ISO C++ entities toplevel namespace is std.
integral_constant
Definition: type_traits:66
is_convertible
Definition: type_traits:1459
_Arg argument_type
argument_type is the type of the argument
Definition: stl_function.h:120
_Result result_type
result_type is the return type
Definition: stl_function.h:123
_Result result_type
result_type is the return type
Definition: stl_function.h:140
_Arg2 second_argument_type
second_argument_type is the type of the second argument
Definition: stl_function.h:137
_Arg1 first_argument_type
first_argument_type is the type of the first argument
Definition: stl_function.h:134
One of the math functors.
Definition: stl_function.h:181
constexpr _Tp operator()(const _Tp &__x, const _Tp &__y) const
Returns the sum.
Definition: stl_function.h:185
One of the math functors.
Definition: stl_function.h:192
One of the math functors.
Definition: stl_function.h:202
One of the math functors.
Definition: stl_function.h:212
One of the math functors.
Definition: stl_function.h:222
One of the math functors.
Definition: stl_function.h:232
One of the comparison functors.
Definition: stl_function.h:366
One of the comparison functors.
Definition: stl_function.h:376
One of the comparison functors.
Definition: stl_function.h:386
One of the comparison functors.
Definition: stl_function.h:396
One of the comparison functors.
Definition: stl_function.h:406
One of the comparison functors.
Definition: stl_function.h:416
One of the Boolean operations functors.
Definition: stl_function.h:801
One of the Boolean operations functors.
Definition: stl_function.h:811
One of the Boolean operations functors.
Definition: stl_function.h:821
One of the negation functors.
One of the negation functors.
One of the adaptors for function pointers.
One of the adaptors for function pointers.
One of the adaptors for member pointers.
One of the adaptors for member pointers.
One of the adaptors for member pointers.
One of the adaptors for member pointers.
One of the adaptors for member pointers.
One of the adaptors for member pointers.
One of the adaptors for member pointers.
One of the adaptors for member pointers.