Makefile.tpl: fix whitespace in licence header
[official-gcc.git] / libstdc++-v3 / include / bits / stl_function.h
blobc9123ccecaea7876594deec131166d74de247360
1 // Functor implementations -*- C++ -*-
3 // Copyright (C) 2001-2024 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.
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.
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.
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/>.
27 * Copyright (c) 1994
28 * Hewlett-Packard Company
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.
39 * Copyright (c) 1996-1998
40 * Silicon Graphics Computer Systems, Inc.
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.
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}
56 #ifndef _STL_FUNCTION_H
57 #define _STL_FUNCTION_H 1
59 #if __cplusplus > 201103L
60 #include <bits/move.h>
61 #endif
63 namespace std _GLIBCXX_VISIBILITY(default)
65 _GLIBCXX_BEGIN_NAMESPACE_VERSION
67 // 20.3.1 base classes
68 /** @defgroup functors Function Objects
69 * @ingroup utilities
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.
79 * Often, functors are only created as temporaries passed to algorithm
80 * calls, rather than being created as named variables.
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.
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.
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.
109 * @{
113 * Helper for defining adaptable unary function objects.
114 * @deprecated Deprecated in C++11, no longer in the standard since C++17.
116 template<typename _Arg, typename _Result>
117 struct unary_function
119 /// @c argument_type is the type of the argument
120 typedef _Arg argument_type;
122 /// @c result_type is the return type
123 typedef _Result result_type;
124 } _GLIBCXX11_DEPRECATED;
127 * Helper for defining adaptable binary function objects.
128 * @deprecated Deprecated in C++11, no longer in the standard since C++17.
130 template<typename _Arg1, typename _Arg2, typename _Result>
131 struct binary_function
133 /// @c first_argument_type is the type of the first argument
134 typedef _Arg1 first_argument_type;
136 /// @c second_argument_type is the type of the second argument
137 typedef _Arg2 second_argument_type;
139 /// @c result_type is the return type
140 typedef _Result result_type;
141 } _GLIBCXX11_DEPRECATED;
142 /** @} */
144 // 20.3.2 arithmetic
146 /** @defgroup arithmetic_functors Arithmetic Function Object Classes
147 * @ingroup functors
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.
153 * @{
156 #if __glibcxx_transparent_operators // C++ >= 14
157 struct __is_transparent; // undefined
159 template<typename _Tp = void>
160 struct plus;
162 template<typename _Tp = void>
163 struct minus;
165 template<typename _Tp = void>
166 struct multiplies;
168 template<typename _Tp = void>
169 struct divides;
171 template<typename _Tp = void>
172 struct modulus;
174 template<typename _Tp = void>
175 struct negate;
176 #endif
178 // Ignore warnings about unary_function and binary_function.
179 #pragma GCC diagnostic push
180 #pragma GCC diagnostic ignored "-Wdeprecated-declarations"
182 /// One of the @link arithmetic_functors math functors@endlink.
183 template<typename _Tp>
184 struct plus : public binary_function<_Tp, _Tp, _Tp>
186 /// Returns the sum
187 _GLIBCXX14_CONSTEXPR
189 operator()(const _Tp& __x, const _Tp& __y) const
190 { return __x + __y; }
193 /// One of the @link arithmetic_functors math functors@endlink.
194 template<typename _Tp>
195 struct minus : public binary_function<_Tp, _Tp, _Tp>
197 _GLIBCXX14_CONSTEXPR
199 operator()(const _Tp& __x, const _Tp& __y) const
200 { return __x - __y; }
203 /// One of the @link arithmetic_functors math functors@endlink.
204 template<typename _Tp>
205 struct multiplies : public binary_function<_Tp, _Tp, _Tp>
207 _GLIBCXX14_CONSTEXPR
209 operator()(const _Tp& __x, const _Tp& __y) const
210 { return __x * __y; }
213 /// One of the @link arithmetic_functors math functors@endlink.
214 template<typename _Tp>
215 struct divides : public binary_function<_Tp, _Tp, _Tp>
217 _GLIBCXX14_CONSTEXPR
219 operator()(const _Tp& __x, const _Tp& __y) const
220 { return __x / __y; }
223 /// One of the @link arithmetic_functors math functors@endlink.
224 template<typename _Tp>
225 struct modulus : public binary_function<_Tp, _Tp, _Tp>
227 _GLIBCXX14_CONSTEXPR
229 operator()(const _Tp& __x, const _Tp& __y) const
230 { return __x % __y; }
233 /// One of the @link arithmetic_functors math functors@endlink.
234 template<typename _Tp>
235 struct negate : public unary_function<_Tp, _Tp>
237 _GLIBCXX14_CONSTEXPR
239 operator()(const _Tp& __x) const
240 { return -__x; }
242 #pragma GCC diagnostic pop
244 #ifdef __glibcxx_transparent_operators // C++ >= 14
245 template<>
246 struct plus<void>
248 template <typename _Tp, typename _Up>
249 _GLIBCXX14_CONSTEXPR
250 auto
251 operator()(_Tp&& __t, _Up&& __u) const
252 noexcept(noexcept(std::forward<_Tp>(__t) + std::forward<_Up>(__u)))
253 -> decltype(std::forward<_Tp>(__t) + std::forward<_Up>(__u))
254 { return std::forward<_Tp>(__t) + std::forward<_Up>(__u); }
256 typedef __is_transparent is_transparent;
259 /// One of the @link arithmetic_functors math functors@endlink.
260 template<>
261 struct minus<void>
263 template <typename _Tp, typename _Up>
264 _GLIBCXX14_CONSTEXPR
265 auto
266 operator()(_Tp&& __t, _Up&& __u) const
267 noexcept(noexcept(std::forward<_Tp>(__t) - std::forward<_Up>(__u)))
268 -> decltype(std::forward<_Tp>(__t) - std::forward<_Up>(__u))
269 { return std::forward<_Tp>(__t) - std::forward<_Up>(__u); }
271 typedef __is_transparent is_transparent;
274 /// One of the @link arithmetic_functors math functors@endlink.
275 template<>
276 struct multiplies<void>
278 template <typename _Tp, typename _Up>
279 _GLIBCXX14_CONSTEXPR
280 auto
281 operator()(_Tp&& __t, _Up&& __u) const
282 noexcept(noexcept(std::forward<_Tp>(__t) * std::forward<_Up>(__u)))
283 -> decltype(std::forward<_Tp>(__t) * std::forward<_Up>(__u))
284 { return std::forward<_Tp>(__t) * std::forward<_Up>(__u); }
286 typedef __is_transparent is_transparent;
289 /// One of the @link arithmetic_functors math functors@endlink.
290 template<>
291 struct divides<void>
293 template <typename _Tp, typename _Up>
294 _GLIBCXX14_CONSTEXPR
295 auto
296 operator()(_Tp&& __t, _Up&& __u) const
297 noexcept(noexcept(std::forward<_Tp>(__t) / std::forward<_Up>(__u)))
298 -> decltype(std::forward<_Tp>(__t) / std::forward<_Up>(__u))
299 { return std::forward<_Tp>(__t) / std::forward<_Up>(__u); }
301 typedef __is_transparent is_transparent;
304 /// One of the @link arithmetic_functors math functors@endlink.
305 template<>
306 struct modulus<void>
308 template <typename _Tp, typename _Up>
309 _GLIBCXX14_CONSTEXPR
310 auto
311 operator()(_Tp&& __t, _Up&& __u) const
312 noexcept(noexcept(std::forward<_Tp>(__t) % std::forward<_Up>(__u)))
313 -> decltype(std::forward<_Tp>(__t) % std::forward<_Up>(__u))
314 { return std::forward<_Tp>(__t) % std::forward<_Up>(__u); }
316 typedef __is_transparent is_transparent;
319 /// One of the @link arithmetic_functors math functors@endlink.
320 template<>
321 struct negate<void>
323 template <typename _Tp>
324 _GLIBCXX14_CONSTEXPR
325 auto
326 operator()(_Tp&& __t) const
327 noexcept(noexcept(-std::forward<_Tp>(__t)))
328 -> decltype(-std::forward<_Tp>(__t))
329 { return -std::forward<_Tp>(__t); }
331 typedef __is_transparent is_transparent;
333 #endif
334 /** @} */
336 // 20.3.3 comparisons
337 /** @defgroup comparison_functors Comparison Classes
338 * @ingroup functors
340 * The library provides six wrapper functors for all the basic comparisons
341 * in C++, like @c <.
343 * @{
345 #if __glibcxx_transparent_operators // C++ >= 14
346 template<typename _Tp = void>
347 struct equal_to;
349 template<typename _Tp = void>
350 struct not_equal_to;
352 template<typename _Tp = void>
353 struct greater;
355 template<typename _Tp = void>
356 struct less;
358 template<typename _Tp = void>
359 struct greater_equal;
361 template<typename _Tp = void>
362 struct less_equal;
363 #endif
365 #pragma GCC diagnostic push
366 #pragma GCC diagnostic ignored "-Wdeprecated-declarations"
368 /// One of the @link comparison_functors comparison functors@endlink.
369 template<typename _Tp>
370 struct equal_to : public binary_function<_Tp, _Tp, bool>
372 _GLIBCXX14_CONSTEXPR
373 bool
374 operator()(const _Tp& __x, const _Tp& __y) const
375 { return __x == __y; }
378 /// One of the @link comparison_functors comparison functors@endlink.
379 template<typename _Tp>
380 struct not_equal_to : public binary_function<_Tp, _Tp, bool>
382 _GLIBCXX14_CONSTEXPR
383 bool
384 operator()(const _Tp& __x, const _Tp& __y) const
385 { return __x != __y; }
388 /// One of the @link comparison_functors comparison functors@endlink.
389 template<typename _Tp>
390 struct greater : public binary_function<_Tp, _Tp, bool>
392 _GLIBCXX14_CONSTEXPR
393 bool
394 operator()(const _Tp& __x, const _Tp& __y) const
395 { return __x > __y; }
398 /// One of the @link comparison_functors comparison functors@endlink.
399 template<typename _Tp>
400 struct less : public binary_function<_Tp, _Tp, bool>
402 _GLIBCXX14_CONSTEXPR
403 bool
404 operator()(const _Tp& __x, const _Tp& __y) const
405 { return __x < __y; }
408 /// One of the @link comparison_functors comparison functors@endlink.
409 template<typename _Tp>
410 struct greater_equal : public binary_function<_Tp, _Tp, bool>
412 _GLIBCXX14_CONSTEXPR
413 bool
414 operator()(const _Tp& __x, const _Tp& __y) const
415 { return __x >= __y; }
418 /// One of the @link comparison_functors comparison functors@endlink.
419 template<typename _Tp>
420 struct less_equal : public binary_function<_Tp, _Tp, bool>
422 _GLIBCXX14_CONSTEXPR
423 bool
424 operator()(const _Tp& __x, const _Tp& __y) const
425 { return __x <= __y; }
428 // Partial specialization of std::greater for pointers.
429 template<typename _Tp>
430 struct greater<_Tp*> : public binary_function<_Tp*, _Tp*, bool>
432 _GLIBCXX14_CONSTEXPR bool
433 operator()(_Tp* __x, _Tp* __y) const _GLIBCXX_NOTHROW
435 #if __cplusplus >= 201402L
436 if (std::__is_constant_evaluated())
437 return __x > __y;
438 #endif
439 return (__UINTPTR_TYPE__)__x > (__UINTPTR_TYPE__)__y;
443 // Partial specialization of std::less for pointers.
444 template<typename _Tp>
445 struct less<_Tp*> : public binary_function<_Tp*, _Tp*, bool>
447 _GLIBCXX14_CONSTEXPR bool
448 operator()(_Tp* __x, _Tp* __y) const _GLIBCXX_NOTHROW
450 #if __cplusplus >= 201402L
451 if (std::__is_constant_evaluated())
452 return __x < __y;
453 #endif
454 return (__UINTPTR_TYPE__)__x < (__UINTPTR_TYPE__)__y;
458 // Partial specialization of std::greater_equal for pointers.
459 template<typename _Tp>
460 struct greater_equal<_Tp*> : public binary_function<_Tp*, _Tp*, bool>
462 _GLIBCXX14_CONSTEXPR bool
463 operator()(_Tp* __x, _Tp* __y) const _GLIBCXX_NOTHROW
465 #if __cplusplus >= 201402L
466 if (std::__is_constant_evaluated())
467 return __x >= __y;
468 #endif
469 return (__UINTPTR_TYPE__)__x >= (__UINTPTR_TYPE__)__y;
473 // Partial specialization of std::less_equal for pointers.
474 template<typename _Tp>
475 struct less_equal<_Tp*> : public binary_function<_Tp*, _Tp*, bool>
477 _GLIBCXX14_CONSTEXPR bool
478 operator()(_Tp* __x, _Tp* __y) const _GLIBCXX_NOTHROW
480 #if __cplusplus >= 201402L
481 if (std::__is_constant_evaluated())
482 return __x <= __y;
483 #endif
484 return (__UINTPTR_TYPE__)__x <= (__UINTPTR_TYPE__)__y;
487 #pragma GCC diagnostic pop
489 #ifdef __glibcxx_transparent_operators // C++ >= 14
490 /// One of the @link comparison_functors comparison functors@endlink.
491 template<>
492 struct equal_to<void>
494 template <typename _Tp, typename _Up>
495 constexpr auto
496 operator()(_Tp&& __t, _Up&& __u) const
497 noexcept(noexcept(std::forward<_Tp>(__t) == std::forward<_Up>(__u)))
498 -> decltype(std::forward<_Tp>(__t) == std::forward<_Up>(__u))
499 { return std::forward<_Tp>(__t) == std::forward<_Up>(__u); }
501 typedef __is_transparent is_transparent;
504 /// One of the @link comparison_functors comparison functors@endlink.
505 template<>
506 struct not_equal_to<void>
508 template <typename _Tp, typename _Up>
509 constexpr auto
510 operator()(_Tp&& __t, _Up&& __u) const
511 noexcept(noexcept(std::forward<_Tp>(__t) != std::forward<_Up>(__u)))
512 -> decltype(std::forward<_Tp>(__t) != std::forward<_Up>(__u))
513 { return std::forward<_Tp>(__t) != std::forward<_Up>(__u); }
515 typedef __is_transparent is_transparent;
518 /// One of the @link comparison_functors comparison functors@endlink.
519 template<>
520 struct greater<void>
522 template <typename _Tp, typename _Up>
523 constexpr auto
524 operator()(_Tp&& __t, _Up&& __u) const
525 noexcept(noexcept(std::forward<_Tp>(__t) > std::forward<_Up>(__u)))
526 -> decltype(std::forward<_Tp>(__t) > std::forward<_Up>(__u))
528 return _S_cmp(std::forward<_Tp>(__t), std::forward<_Up>(__u),
529 __ptr_cmp<_Tp, _Up>{});
532 template<typename _Tp, typename _Up>
533 constexpr bool
534 operator()(_Tp* __t, _Up* __u) const noexcept
535 { return greater<common_type_t<_Tp*, _Up*>>{}(__t, __u); }
537 typedef __is_transparent is_transparent;
539 private:
540 template <typename _Tp, typename _Up>
541 static constexpr decltype(auto)
542 _S_cmp(_Tp&& __t, _Up&& __u, false_type)
543 { return std::forward<_Tp>(__t) > std::forward<_Up>(__u); }
545 template <typename _Tp, typename _Up>
546 static constexpr bool
547 _S_cmp(_Tp&& __t, _Up&& __u, true_type) noexcept
549 return greater<const volatile void*>{}(
550 static_cast<const volatile void*>(std::forward<_Tp>(__t)),
551 static_cast<const volatile void*>(std::forward<_Up>(__u)));
554 // True if there is no viable operator> member function.
555 template<typename _Tp, typename _Up, typename = void>
556 struct __not_overloaded2 : true_type { };
558 // False if we can call T.operator>(U)
559 template<typename _Tp, typename _Up>
560 struct __not_overloaded2<_Tp, _Up, __void_t<
561 decltype(std::declval<_Tp>().operator>(std::declval<_Up>()))>>
562 : false_type { };
564 // True if there is no overloaded operator> for these operands.
565 template<typename _Tp, typename _Up, typename = void>
566 struct __not_overloaded : __not_overloaded2<_Tp, _Up> { };
568 // False if we can call operator>(T,U)
569 template<typename _Tp, typename _Up>
570 struct __not_overloaded<_Tp, _Up, __void_t<
571 decltype(operator>(std::declval<_Tp>(), std::declval<_Up>()))>>
572 : false_type { };
574 template<typename _Tp, typename _Up>
575 using __ptr_cmp = __and_<__not_overloaded<_Tp, _Up>,
576 is_convertible<_Tp, const volatile void*>,
577 is_convertible<_Up, const volatile void*>>;
580 /// One of the @link comparison_functors comparison functors@endlink.
581 template<>
582 struct less<void>
584 template <typename _Tp, typename _Up>
585 constexpr auto
586 operator()(_Tp&& __t, _Up&& __u) const
587 noexcept(noexcept(std::forward<_Tp>(__t) < std::forward<_Up>(__u)))
588 -> decltype(std::forward<_Tp>(__t) < std::forward<_Up>(__u))
590 return _S_cmp(std::forward<_Tp>(__t), std::forward<_Up>(__u),
591 __ptr_cmp<_Tp, _Up>{});
594 template<typename _Tp, typename _Up>
595 constexpr bool
596 operator()(_Tp* __t, _Up* __u) const noexcept
597 { return less<common_type_t<_Tp*, _Up*>>{}(__t, __u); }
599 typedef __is_transparent is_transparent;
601 private:
602 template <typename _Tp, typename _Up>
603 static constexpr decltype(auto)
604 _S_cmp(_Tp&& __t, _Up&& __u, false_type)
605 { return std::forward<_Tp>(__t) < std::forward<_Up>(__u); }
607 template <typename _Tp, typename _Up>
608 static constexpr bool
609 _S_cmp(_Tp&& __t, _Up&& __u, true_type) noexcept
611 return less<const volatile void*>{}(
612 static_cast<const volatile void*>(std::forward<_Tp>(__t)),
613 static_cast<const volatile void*>(std::forward<_Up>(__u)));
616 // True if there is no viable operator< member function.
617 template<typename _Tp, typename _Up, typename = void>
618 struct __not_overloaded2 : true_type { };
620 // False if we can call T.operator<(U)
621 template<typename _Tp, typename _Up>
622 struct __not_overloaded2<_Tp, _Up, __void_t<
623 decltype(std::declval<_Tp>().operator<(std::declval<_Up>()))>>
624 : false_type { };
626 // True if there is no overloaded operator< for these operands.
627 template<typename _Tp, typename _Up, typename = void>
628 struct __not_overloaded : __not_overloaded2<_Tp, _Up> { };
630 // False if we can call operator<(T,U)
631 template<typename _Tp, typename _Up>
632 struct __not_overloaded<_Tp, _Up, __void_t<
633 decltype(operator<(std::declval<_Tp>(), std::declval<_Up>()))>>
634 : false_type { };
636 template<typename _Tp, typename _Up>
637 using __ptr_cmp = __and_<__not_overloaded<_Tp, _Up>,
638 is_convertible<_Tp, const volatile void*>,
639 is_convertible<_Up, const volatile void*>>;
642 /// One of the @link comparison_functors comparison functors@endlink.
643 template<>
644 struct greater_equal<void>
646 template <typename _Tp, typename _Up>
647 constexpr auto
648 operator()(_Tp&& __t, _Up&& __u) const
649 noexcept(noexcept(std::forward<_Tp>(__t) >= std::forward<_Up>(__u)))
650 -> decltype(std::forward<_Tp>(__t) >= std::forward<_Up>(__u))
652 return _S_cmp(std::forward<_Tp>(__t), std::forward<_Up>(__u),
653 __ptr_cmp<_Tp, _Up>{});
656 template<typename _Tp, typename _Up>
657 constexpr bool
658 operator()(_Tp* __t, _Up* __u) const noexcept
659 { return greater_equal<common_type_t<_Tp*, _Up*>>{}(__t, __u); }
661 typedef __is_transparent is_transparent;
663 private:
664 template <typename _Tp, typename _Up>
665 static constexpr decltype(auto)
666 _S_cmp(_Tp&& __t, _Up&& __u, false_type)
667 { return std::forward<_Tp>(__t) >= std::forward<_Up>(__u); }
669 template <typename _Tp, typename _Up>
670 static constexpr bool
671 _S_cmp(_Tp&& __t, _Up&& __u, true_type) noexcept
673 return greater_equal<const volatile void*>{}(
674 static_cast<const volatile void*>(std::forward<_Tp>(__t)),
675 static_cast<const volatile void*>(std::forward<_Up>(__u)));
678 // True if there is no viable operator>= member function.
679 template<typename _Tp, typename _Up, typename = void>
680 struct __not_overloaded2 : true_type { };
682 // False if we can call T.operator>=(U)
683 template<typename _Tp, typename _Up>
684 struct __not_overloaded2<_Tp, _Up, __void_t<
685 decltype(std::declval<_Tp>().operator>=(std::declval<_Up>()))>>
686 : false_type { };
688 // True if there is no overloaded operator>= for these operands.
689 template<typename _Tp, typename _Up, typename = void>
690 struct __not_overloaded : __not_overloaded2<_Tp, _Up> { };
692 // False if we can call operator>=(T,U)
693 template<typename _Tp, typename _Up>
694 struct __not_overloaded<_Tp, _Up, __void_t<
695 decltype(operator>=(std::declval<_Tp>(), std::declval<_Up>()))>>
696 : false_type { };
698 template<typename _Tp, typename _Up>
699 using __ptr_cmp = __and_<__not_overloaded<_Tp, _Up>,
700 is_convertible<_Tp, const volatile void*>,
701 is_convertible<_Up, const volatile void*>>;
704 /// One of the @link comparison_functors comparison functors@endlink.
705 template<>
706 struct less_equal<void>
708 template <typename _Tp, typename _Up>
709 constexpr auto
710 operator()(_Tp&& __t, _Up&& __u) const
711 noexcept(noexcept(std::forward<_Tp>(__t) <= std::forward<_Up>(__u)))
712 -> decltype(std::forward<_Tp>(__t) <= std::forward<_Up>(__u))
714 return _S_cmp(std::forward<_Tp>(__t), std::forward<_Up>(__u),
715 __ptr_cmp<_Tp, _Up>{});
718 template<typename _Tp, typename _Up>
719 constexpr bool
720 operator()(_Tp* __t, _Up* __u) const noexcept
721 { return less_equal<common_type_t<_Tp*, _Up*>>{}(__t, __u); }
723 typedef __is_transparent is_transparent;
725 private:
726 template <typename _Tp, typename _Up>
727 static constexpr decltype(auto)
728 _S_cmp(_Tp&& __t, _Up&& __u, false_type)
729 { return std::forward<_Tp>(__t) <= std::forward<_Up>(__u); }
731 template <typename _Tp, typename _Up>
732 static constexpr bool
733 _S_cmp(_Tp&& __t, _Up&& __u, true_type) noexcept
735 return less_equal<const volatile void*>{}(
736 static_cast<const volatile void*>(std::forward<_Tp>(__t)),
737 static_cast<const volatile void*>(std::forward<_Up>(__u)));
740 // True if there is no viable operator<= member function.
741 template<typename _Tp, typename _Up, typename = void>
742 struct __not_overloaded2 : true_type { };
744 // False if we can call T.operator<=(U)
745 template<typename _Tp, typename _Up>
746 struct __not_overloaded2<_Tp, _Up, __void_t<
747 decltype(std::declval<_Tp>().operator<=(std::declval<_Up>()))>>
748 : false_type { };
750 // True if there is no overloaded operator<= for these operands.
751 template<typename _Tp, typename _Up, typename = void>
752 struct __not_overloaded : __not_overloaded2<_Tp, _Up> { };
754 // False if we can call operator<=(T,U)
755 template<typename _Tp, typename _Up>
756 struct __not_overloaded<_Tp, _Up, __void_t<
757 decltype(operator<=(std::declval<_Tp>(), std::declval<_Up>()))>>
758 : false_type { };
760 template<typename _Tp, typename _Up>
761 using __ptr_cmp = __and_<__not_overloaded<_Tp, _Up>,
762 is_convertible<_Tp, const volatile void*>,
763 is_convertible<_Up, const volatile void*>>;
765 #endif // __glibcxx_transparent_operators
766 /** @} */
768 // 20.3.4 logical operations
769 /** @defgroup logical_functors Boolean Operations Classes
770 * @ingroup functors
772 * The library provides function objects for the logical operations:
773 * `&&`, `||`, and `!`.
775 * @{
777 #ifdef __glibcxx_transparent_operators // C++ >= 14
778 template<typename _Tp = void>
779 struct logical_and;
781 template<typename _Tp = void>
782 struct logical_or;
784 template<typename _Tp = void>
785 struct logical_not;
786 #endif
788 #pragma GCC diagnostic push
789 #pragma GCC diagnostic ignored "-Wdeprecated-declarations"
791 /// One of the @link logical_functors Boolean operations functors@endlink.
792 template<typename _Tp>
793 struct logical_and : public binary_function<_Tp, _Tp, bool>
795 _GLIBCXX14_CONSTEXPR
796 bool
797 operator()(const _Tp& __x, const _Tp& __y) const
798 { return __x && __y; }
801 /// One of the @link logical_functors Boolean operations functors@endlink.
802 template<typename _Tp>
803 struct logical_or : public binary_function<_Tp, _Tp, bool>
805 _GLIBCXX14_CONSTEXPR
806 bool
807 operator()(const _Tp& __x, const _Tp& __y) const
808 { return __x || __y; }
811 /// One of the @link logical_functors Boolean operations functors@endlink.
812 template<typename _Tp>
813 struct logical_not : public unary_function<_Tp, bool>
815 _GLIBCXX14_CONSTEXPR
816 bool
817 operator()(const _Tp& __x) const
818 { return !__x; }
820 #pragma GCC diagnostic pop
822 #ifdef __glibcxx_transparent_operators // C++ >= 14
823 /// One of the @link logical_functors Boolean operations functors@endlink.
824 template<>
825 struct logical_and<void>
827 template <typename _Tp, typename _Up>
828 _GLIBCXX14_CONSTEXPR
829 auto
830 operator()(_Tp&& __t, _Up&& __u) const
831 noexcept(noexcept(std::forward<_Tp>(__t) && std::forward<_Up>(__u)))
832 -> decltype(std::forward<_Tp>(__t) && std::forward<_Up>(__u))
833 { return std::forward<_Tp>(__t) && std::forward<_Up>(__u); }
835 typedef __is_transparent is_transparent;
838 /// One of the @link logical_functors Boolean operations functors@endlink.
839 template<>
840 struct logical_or<void>
842 template <typename _Tp, typename _Up>
843 _GLIBCXX14_CONSTEXPR
844 auto
845 operator()(_Tp&& __t, _Up&& __u) const
846 noexcept(noexcept(std::forward<_Tp>(__t) || std::forward<_Up>(__u)))
847 -> decltype(std::forward<_Tp>(__t) || std::forward<_Up>(__u))
848 { return std::forward<_Tp>(__t) || std::forward<_Up>(__u); }
850 typedef __is_transparent is_transparent;
853 /// One of the @link logical_functors Boolean operations functors@endlink.
854 template<>
855 struct logical_not<void>
857 template <typename _Tp>
858 _GLIBCXX14_CONSTEXPR
859 auto
860 operator()(_Tp&& __t) const
861 noexcept(noexcept(!std::forward<_Tp>(__t)))
862 -> decltype(!std::forward<_Tp>(__t))
863 { return !std::forward<_Tp>(__t); }
865 typedef __is_transparent is_transparent;
867 #endif // __glibcxx_transparent_operators
868 /** @} */
870 #ifdef __glibcxx_transparent_operators // C++ >= 14
871 template<typename _Tp = void>
872 struct bit_and;
874 template<typename _Tp = void>
875 struct bit_or;
877 template<typename _Tp = void>
878 struct bit_xor;
880 template<typename _Tp = void>
881 struct bit_not;
882 #endif
884 #pragma GCC diagnostic push
885 #pragma GCC diagnostic ignored "-Wdeprecated-declarations"
887 // _GLIBCXX_RESOLVE_LIB_DEFECTS
888 // DR 660. Missing Bitwise Operations.
889 template<typename _Tp>
890 struct bit_and : public binary_function<_Tp, _Tp, _Tp>
892 _GLIBCXX14_CONSTEXPR
894 operator()(const _Tp& __x, const _Tp& __y) const
895 { return __x & __y; }
898 template<typename _Tp>
899 struct bit_or : public binary_function<_Tp, _Tp, _Tp>
901 _GLIBCXX14_CONSTEXPR
903 operator()(const _Tp& __x, const _Tp& __y) const
904 { return __x | __y; }
907 template<typename _Tp>
908 struct bit_xor : public binary_function<_Tp, _Tp, _Tp>
910 _GLIBCXX14_CONSTEXPR
912 operator()(const _Tp& __x, const _Tp& __y) const
913 { return __x ^ __y; }
916 template<typename _Tp>
917 struct bit_not : public unary_function<_Tp, _Tp>
919 _GLIBCXX14_CONSTEXPR
921 operator()(const _Tp& __x) const
922 { return ~__x; }
924 #pragma GCC diagnostic pop
926 #ifdef __glibcxx_transparent_operators // C++ >= 14
927 template <>
928 struct bit_and<void>
930 template <typename _Tp, typename _Up>
931 _GLIBCXX14_CONSTEXPR
932 auto
933 operator()(_Tp&& __t, _Up&& __u) const
934 noexcept(noexcept(std::forward<_Tp>(__t) & std::forward<_Up>(__u)))
935 -> decltype(std::forward<_Tp>(__t) & std::forward<_Up>(__u))
936 { return std::forward<_Tp>(__t) & std::forward<_Up>(__u); }
938 typedef __is_transparent is_transparent;
941 template <>
942 struct bit_or<void>
944 template <typename _Tp, typename _Up>
945 _GLIBCXX14_CONSTEXPR
946 auto
947 operator()(_Tp&& __t, _Up&& __u) const
948 noexcept(noexcept(std::forward<_Tp>(__t) | std::forward<_Up>(__u)))
949 -> decltype(std::forward<_Tp>(__t) | std::forward<_Up>(__u))
950 { return std::forward<_Tp>(__t) | std::forward<_Up>(__u); }
952 typedef __is_transparent is_transparent;
955 template <>
956 struct bit_xor<void>
958 template <typename _Tp, typename _Up>
959 _GLIBCXX14_CONSTEXPR
960 auto
961 operator()(_Tp&& __t, _Up&& __u) const
962 noexcept(noexcept(std::forward<_Tp>(__t) ^ std::forward<_Up>(__u)))
963 -> decltype(std::forward<_Tp>(__t) ^ std::forward<_Up>(__u))
964 { return std::forward<_Tp>(__t) ^ std::forward<_Up>(__u); }
966 typedef __is_transparent is_transparent;
969 template <>
970 struct bit_not<void>
972 template <typename _Tp>
973 _GLIBCXX14_CONSTEXPR
974 auto
975 operator()(_Tp&& __t) const
976 noexcept(noexcept(~std::forward<_Tp>(__t)))
977 -> decltype(~std::forward<_Tp>(__t))
978 { return ~std::forward<_Tp>(__t); }
980 typedef __is_transparent is_transparent;
982 #endif // C++14
984 #pragma GCC diagnostic push
985 #pragma GCC diagnostic ignored "-Wdeprecated-declarations"
987 // 20.3.5 negators
988 /** @defgroup negators Negators
989 * @ingroup functors
991 * The function templates `not1` and `not2` are function object adaptors,
992 * which each take a predicate functor and wrap it in an instance of
993 * `unary_negate` or `binary_negate`, respectively. Those classes are
994 * functors whose `operator()` evaluates the wrapped predicate function
995 * and then returns the negation of the result.
997 * For example, given a vector of integers and a trivial predicate,
998 * \code
999 * struct IntGreaterThanThree
1000 * : public std::unary_function<int, bool>
1002 * bool operator() (int x) const { return x > 3; }
1003 * };
1005 * std::find_if (v.begin(), v.end(), not1(IntGreaterThanThree()));
1006 * \endcode
1007 * The call to `find_if` will locate the first index (i) of `v` for which
1008 * `!(v[i] > 3)` is true.
1010 * The not1/unary_negate combination works on predicates taking a single
1011 * argument. The not2/binary_negate combination works on predicates taking
1012 * two arguments.
1014 * @deprecated Deprecated in C++17, no longer in the standard since C++20.
1015 * Use `not_fn` instead.
1017 * @{
1019 /// One of the @link negators negation functors@endlink.
1020 template<typename _Predicate>
1021 class _GLIBCXX17_DEPRECATED unary_negate
1022 : public unary_function<typename _Predicate::argument_type, bool>
1024 protected:
1025 _Predicate _M_pred;
1027 public:
1028 _GLIBCXX14_CONSTEXPR
1029 explicit
1030 unary_negate(const _Predicate& __x) : _M_pred(__x) { }
1032 _GLIBCXX14_CONSTEXPR
1033 bool
1034 operator()(const typename _Predicate::argument_type& __x) const
1035 { return !_M_pred(__x); }
1038 /// One of the @link negators negation functors@endlink.
1039 template<typename _Predicate>
1040 _GLIBCXX17_DEPRECATED_SUGGEST("std::not_fn")
1041 _GLIBCXX14_CONSTEXPR
1042 inline unary_negate<_Predicate>
1043 not1(const _Predicate& __pred)
1044 { return unary_negate<_Predicate>(__pred); }
1046 /// One of the @link negators negation functors@endlink.
1047 template<typename _Predicate>
1048 class _GLIBCXX17_DEPRECATED binary_negate
1049 : public binary_function<typename _Predicate::first_argument_type,
1050 typename _Predicate::second_argument_type, bool>
1052 protected:
1053 _Predicate _M_pred;
1055 public:
1056 _GLIBCXX14_CONSTEXPR
1057 explicit
1058 binary_negate(const _Predicate& __x) : _M_pred(__x) { }
1060 _GLIBCXX14_CONSTEXPR
1061 bool
1062 operator()(const typename _Predicate::first_argument_type& __x,
1063 const typename _Predicate::second_argument_type& __y) const
1064 { return !_M_pred(__x, __y); }
1067 /// One of the @link negators negation functors@endlink.
1068 template<typename _Predicate>
1069 _GLIBCXX17_DEPRECATED_SUGGEST("std::not_fn")
1070 _GLIBCXX14_CONSTEXPR
1071 inline binary_negate<_Predicate>
1072 not2(const _Predicate& __pred)
1073 { return binary_negate<_Predicate>(__pred); }
1074 /** @} */
1076 // 20.3.7 adaptors pointers functions
1077 /** @defgroup pointer_adaptors Adaptors for pointers to functions
1078 * @ingroup functors
1080 * The advantage of function objects over pointers to functions is that
1081 * the objects in the standard library declare nested typedefs describing
1082 * their argument and result types with uniform names (e.g., `result_type`
1083 * from the base classes `unary_function` and `binary_function`).
1084 * Sometimes those typedefs are required, not just optional.
1086 * Adaptors are provided to turn pointers to unary (single-argument) and
1087 * binary (double-argument) functions into function objects. The
1088 * long-winded functor `pointer_to_unary_function` is constructed with a
1089 * function pointer `f`, and its `operator()` called with argument `x`
1090 * returns `f(x)`. The functor `pointer_to_binary_function` does the same
1091 * thing, but with a double-argument `f` and `operator()`.
1093 * The function `ptr_fun` takes a pointer-to-function `f` and constructs
1094 * an instance of the appropriate functor.
1096 * @deprecated Deprecated in C++11, no longer in the standard since C++17.
1098 * @{
1100 /// One of the @link pointer_adaptors adaptors for function pointers@endlink.
1101 template<typename _Arg, typename _Result>
1102 class pointer_to_unary_function : public unary_function<_Arg, _Result>
1104 protected:
1105 _Result (*_M_ptr)(_Arg);
1107 public:
1108 pointer_to_unary_function() { }
1110 explicit
1111 pointer_to_unary_function(_Result (*__x)(_Arg))
1112 : _M_ptr(__x) { }
1114 _Result
1115 operator()(_Arg __x) const
1116 { return _M_ptr(__x); }
1117 } _GLIBCXX11_DEPRECATED;
1119 /// One of the @link pointer_adaptors adaptors for function pointers@endlink.
1120 template<typename _Arg, typename _Result>
1121 _GLIBCXX11_DEPRECATED_SUGGEST("std::function")
1122 inline pointer_to_unary_function<_Arg, _Result>
1123 ptr_fun(_Result (*__x)(_Arg))
1124 { return pointer_to_unary_function<_Arg, _Result>(__x); }
1126 /// One of the @link pointer_adaptors adaptors for function pointers@endlink.
1127 template<typename _Arg1, typename _Arg2, typename _Result>
1128 class pointer_to_binary_function
1129 : public binary_function<_Arg1, _Arg2, _Result>
1131 protected:
1132 _Result (*_M_ptr)(_Arg1, _Arg2);
1134 public:
1135 pointer_to_binary_function() { }
1137 explicit
1138 pointer_to_binary_function(_Result (*__x)(_Arg1, _Arg2))
1139 : _M_ptr(__x) { }
1141 _Result
1142 operator()(_Arg1 __x, _Arg2 __y) const
1143 { return _M_ptr(__x, __y); }
1144 } _GLIBCXX11_DEPRECATED;
1146 /// One of the @link pointer_adaptors adaptors for function pointers@endlink.
1147 template<typename _Arg1, typename _Arg2, typename _Result>
1148 _GLIBCXX11_DEPRECATED_SUGGEST("std::function")
1149 inline pointer_to_binary_function<_Arg1, _Arg2, _Result>
1150 ptr_fun(_Result (*__x)(_Arg1, _Arg2))
1151 { return pointer_to_binary_function<_Arg1, _Arg2, _Result>(__x); }
1152 /** @} */
1154 template<typename _Tp>
1155 struct _Identity
1156 : public unary_function<_Tp, _Tp>
1158 _Tp&
1159 operator()(_Tp& __x) const
1160 { return __x; }
1162 const _Tp&
1163 operator()(const _Tp& __x) const
1164 { return __x; }
1167 // Partial specialization, avoids confusing errors in e.g. std::set<const T>.
1168 template<typename _Tp> struct _Identity<const _Tp> : _Identity<_Tp> { };
1170 template<typename _Pair>
1171 struct _Select1st
1172 : public unary_function<_Pair, typename _Pair::first_type>
1174 typename _Pair::first_type&
1175 operator()(_Pair& __x) const
1176 { return __x.first; }
1178 const typename _Pair::first_type&
1179 operator()(const _Pair& __x) const
1180 { return __x.first; }
1182 #if __cplusplus >= 201103L
1183 template<typename _Pair2>
1184 typename _Pair2::first_type&
1185 operator()(_Pair2& __x) const
1186 { return __x.first; }
1188 template<typename _Pair2>
1189 const typename _Pair2::first_type&
1190 operator()(const _Pair2& __x) const
1191 { return __x.first; }
1192 #endif
1195 template<typename _Pair>
1196 struct _Select2nd
1197 : public unary_function<_Pair, typename _Pair::second_type>
1199 typename _Pair::second_type&
1200 operator()(_Pair& __x) const
1201 { return __x.second; }
1203 const typename _Pair::second_type&
1204 operator()(const _Pair& __x) const
1205 { return __x.second; }
1208 // 20.3.8 adaptors pointers members
1209 /** @defgroup ptrmem_adaptors Adaptors for pointers to members
1210 * @ingroup functors
1212 * There are a total of 8 = 2^3 function objects in this family.
1213 * (1) Member functions taking no arguments vs member functions taking
1214 * one argument.
1215 * (2) Call through pointer vs call through reference.
1216 * (3) Const vs non-const member function.
1218 * All of this complexity is in the function objects themselves. You can
1219 * ignore it by using the helper function `mem_fun` and `mem_fun_ref`,
1220 * which create whichever type of adaptor is appropriate.
1222 * @deprecated Deprecated in C++11, no longer in the standard since C++17.
1223 * Use `mem_fn` instead.
1225 * @{
1227 /// One of the @link ptrmem_adaptors adaptors for member pointers@endlink.
1228 template<typename _Ret, typename _Tp>
1229 class mem_fun_t : public unary_function<_Tp*, _Ret>
1231 public:
1232 explicit
1233 mem_fun_t(_Ret (_Tp::*__pf)())
1234 : _M_f(__pf) { }
1236 _Ret
1237 operator()(_Tp* __p) const
1238 { return (__p->*_M_f)(); }
1240 private:
1241 _Ret (_Tp::*_M_f)();
1242 } _GLIBCXX11_DEPRECATED;
1244 /// One of the @link ptrmem_adaptors adaptors for member pointers@endlink.
1245 template<typename _Ret, typename _Tp>
1246 class const_mem_fun_t : public unary_function<const _Tp*, _Ret>
1248 public:
1249 explicit
1250 const_mem_fun_t(_Ret (_Tp::*__pf)() const)
1251 : _M_f(__pf) { }
1253 _Ret
1254 operator()(const _Tp* __p) const
1255 { return (__p->*_M_f)(); }
1257 private:
1258 _Ret (_Tp::*_M_f)() const;
1259 } _GLIBCXX11_DEPRECATED;
1261 /// One of the @link ptrmem_adaptors adaptors for member pointers@endlink.
1262 template<typename _Ret, typename _Tp>
1263 class mem_fun_ref_t : public unary_function<_Tp, _Ret>
1265 public:
1266 explicit
1267 mem_fun_ref_t(_Ret (_Tp::*__pf)())
1268 : _M_f(__pf) { }
1270 _Ret
1271 operator()(_Tp& __r) const
1272 { return (__r.*_M_f)(); }
1274 private:
1275 _Ret (_Tp::*_M_f)();
1276 } _GLIBCXX11_DEPRECATED;
1278 /// One of the @link ptrmem_adaptors adaptors for member pointers@endlink.
1279 template<typename _Ret, typename _Tp>
1280 class const_mem_fun_ref_t : public unary_function<_Tp, _Ret>
1282 public:
1283 explicit
1284 const_mem_fun_ref_t(_Ret (_Tp::*__pf)() const)
1285 : _M_f(__pf) { }
1287 _Ret
1288 operator()(const _Tp& __r) const
1289 { return (__r.*_M_f)(); }
1291 private:
1292 _Ret (_Tp::*_M_f)() const;
1293 } _GLIBCXX11_DEPRECATED;
1295 /// One of the @link ptrmem_adaptors adaptors for member pointers@endlink.
1296 template<typename _Ret, typename _Tp, typename _Arg>
1297 class mem_fun1_t : public binary_function<_Tp*, _Arg, _Ret>
1299 public:
1300 explicit
1301 mem_fun1_t(_Ret (_Tp::*__pf)(_Arg))
1302 : _M_f(__pf) { }
1304 _Ret
1305 operator()(_Tp* __p, _Arg __x) const
1306 { return (__p->*_M_f)(__x); }
1308 private:
1309 _Ret (_Tp::*_M_f)(_Arg);
1310 } _GLIBCXX11_DEPRECATED;
1312 /// One of the @link ptrmem_adaptors adaptors for member pointers@endlink.
1313 template<typename _Ret, typename _Tp, typename _Arg>
1314 class const_mem_fun1_t : public binary_function<const _Tp*, _Arg, _Ret>
1316 public:
1317 explicit
1318 const_mem_fun1_t(_Ret (_Tp::*__pf)(_Arg) const)
1319 : _M_f(__pf) { }
1321 _Ret
1322 operator()(const _Tp* __p, _Arg __x) const
1323 { return (__p->*_M_f)(__x); }
1325 private:
1326 _Ret (_Tp::*_M_f)(_Arg) const;
1327 } _GLIBCXX11_DEPRECATED;
1329 /// One of the @link ptrmem_adaptors adaptors for member pointers@endlink.
1330 template<typename _Ret, typename _Tp, typename _Arg>
1331 class mem_fun1_ref_t : public binary_function<_Tp, _Arg, _Ret>
1333 public:
1334 explicit
1335 mem_fun1_ref_t(_Ret (_Tp::*__pf)(_Arg))
1336 : _M_f(__pf) { }
1338 _Ret
1339 operator()(_Tp& __r, _Arg __x) const
1340 { return (__r.*_M_f)(__x); }
1342 private:
1343 _Ret (_Tp::*_M_f)(_Arg);
1344 } _GLIBCXX11_DEPRECATED;
1346 /// One of the @link ptrmem_adaptors adaptors for member pointers@endlink.
1347 template<typename _Ret, typename _Tp, typename _Arg>
1348 class const_mem_fun1_ref_t : public binary_function<_Tp, _Arg, _Ret>
1350 public:
1351 explicit
1352 const_mem_fun1_ref_t(_Ret (_Tp::*__pf)(_Arg) const)
1353 : _M_f(__pf) { }
1355 _Ret
1356 operator()(const _Tp& __r, _Arg __x) const
1357 { return (__r.*_M_f)(__x); }
1359 private:
1360 _Ret (_Tp::*_M_f)(_Arg) const;
1361 } _GLIBCXX11_DEPRECATED;
1363 // Mem_fun adaptor helper functions. There are only two:
1364 // mem_fun and mem_fun_ref.
1365 template<typename _Ret, typename _Tp>
1366 _GLIBCXX11_DEPRECATED_SUGGEST("std::mem_fn")
1367 inline mem_fun_t<_Ret, _Tp>
1368 mem_fun(_Ret (_Tp::*__f)())
1369 { return mem_fun_t<_Ret, _Tp>(__f); }
1371 template<typename _Ret, typename _Tp>
1372 _GLIBCXX11_DEPRECATED_SUGGEST("std::mem_fn")
1373 inline const_mem_fun_t<_Ret, _Tp>
1374 mem_fun(_Ret (_Tp::*__f)() const)
1375 { return const_mem_fun_t<_Ret, _Tp>(__f); }
1377 template<typename _Ret, typename _Tp>
1378 _GLIBCXX11_DEPRECATED_SUGGEST("std::mem_fn")
1379 inline mem_fun_ref_t<_Ret, _Tp>
1380 mem_fun_ref(_Ret (_Tp::*__f)())
1381 { return mem_fun_ref_t<_Ret, _Tp>(__f); }
1383 template<typename _Ret, typename _Tp>
1384 _GLIBCXX11_DEPRECATED_SUGGEST("std::mem_fn")
1385 inline const_mem_fun_ref_t<_Ret, _Tp>
1386 mem_fun_ref(_Ret (_Tp::*__f)() const)
1387 { return const_mem_fun_ref_t<_Ret, _Tp>(__f); }
1389 template<typename _Ret, typename _Tp, typename _Arg>
1390 _GLIBCXX11_DEPRECATED_SUGGEST("std::mem_fn")
1391 inline mem_fun1_t<_Ret, _Tp, _Arg>
1392 mem_fun(_Ret (_Tp::*__f)(_Arg))
1393 { return mem_fun1_t<_Ret, _Tp, _Arg>(__f); }
1395 template<typename _Ret, typename _Tp, typename _Arg>
1396 _GLIBCXX11_DEPRECATED_SUGGEST("std::mem_fn")
1397 inline const_mem_fun1_t<_Ret, _Tp, _Arg>
1398 mem_fun(_Ret (_Tp::*__f)(_Arg) const)
1399 { return const_mem_fun1_t<_Ret, _Tp, _Arg>(__f); }
1401 template<typename _Ret, typename _Tp, typename _Arg>
1402 _GLIBCXX11_DEPRECATED_SUGGEST("std::mem_fn")
1403 inline mem_fun1_ref_t<_Ret, _Tp, _Arg>
1404 mem_fun_ref(_Ret (_Tp::*__f)(_Arg))
1405 { return mem_fun1_ref_t<_Ret, _Tp, _Arg>(__f); }
1407 template<typename _Ret, typename _Tp, typename _Arg>
1408 _GLIBCXX11_DEPRECATED_SUGGEST("std::mem_fn")
1409 inline const_mem_fun1_ref_t<_Ret, _Tp, _Arg>
1410 mem_fun_ref(_Ret (_Tp::*__f)(_Arg) const)
1411 { return const_mem_fun1_ref_t<_Ret, _Tp, _Arg>(__f); }
1412 #pragma GCC diagnostic pop
1414 /** @} */
1416 #ifdef __glibcxx_transparent_operators // C++ >= 14
1417 template<typename _Func, typename _SfinaeType, typename = __void_t<>>
1418 struct __has_is_transparent
1419 { };
1421 template<typename _Func, typename _SfinaeType>
1422 struct __has_is_transparent<_Func, _SfinaeType,
1423 __void_t<typename _Func::is_transparent>>
1424 { typedef void type; };
1426 template<typename _Func, typename _SfinaeType>
1427 using __has_is_transparent_t
1428 = typename __has_is_transparent<_Func, _SfinaeType>::type;
1429 #endif
1431 _GLIBCXX_END_NAMESPACE_VERSION
1432 } // namespace
1434 #if (__cplusplus < 201103L) || _GLIBCXX_USE_DEPRECATED
1435 # include <backward/binders.h>
1436 #endif
1438 #endif /* _STL_FUNCTION_H */