]> git.ipfire.org Git - thirdparty/gcc.git/blob - libstdc++-v3/include/bits/stl_function.h
libstdc++: Define std::__is_constant_evaluated() for internal use
[thirdparty/gcc.git] / libstdc++-v3 / include / bits / stl_function.h
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>
117 struct unary_function
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>
131 struct binary_function
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 if (std::__is_constant_evaluated())
432 return __x > __y;
433 #endif
434 return (__UINTPTR_TYPE__)__x > (__UINTPTR_TYPE__)__y;
435 }
436 };
437
438 // Partial specialization of std::less for pointers.
439 template<typename _Tp>
440 struct less<_Tp*> : public binary_function<_Tp*, _Tp*, bool>
441 {
442 _GLIBCXX14_CONSTEXPR bool
443 operator()(_Tp* __x, _Tp* __y) const _GLIBCXX_NOTHROW
444 {
445 #if __cplusplus >= 201402L
446 if (std::__is_constant_evaluated())
447 return __x < __y;
448 #endif
449 return (__UINTPTR_TYPE__)__x < (__UINTPTR_TYPE__)__y;
450 }
451 };
452
453 // Partial specialization of std::greater_equal for pointers.
454 template<typename _Tp>
455 struct greater_equal<_Tp*> : public binary_function<_Tp*, _Tp*, bool>
456 {
457 _GLIBCXX14_CONSTEXPR bool
458 operator()(_Tp* __x, _Tp* __y) const _GLIBCXX_NOTHROW
459 {
460 #if __cplusplus >= 201402L
461 if (std::__is_constant_evaluated())
462 return __x >= __y;
463 #endif
464 return (__UINTPTR_TYPE__)__x >= (__UINTPTR_TYPE__)__y;
465 }
466 };
467
468 // Partial specialization of std::less_equal for pointers.
469 template<typename _Tp>
470 struct less_equal<_Tp*> : public binary_function<_Tp*, _Tp*, bool>
471 {
472 _GLIBCXX14_CONSTEXPR bool
473 operator()(_Tp* __x, _Tp* __y) const _GLIBCXX_NOTHROW
474 {
475 #if __cplusplus >= 201402L
476 if (std::__is_constant_evaluated())
477 return __x <= __y;
478 #endif
479 return (__UINTPTR_TYPE__)__x <= (__UINTPTR_TYPE__)__y;
480 }
481 };
482
483 #if __cplusplus >= 201402L
484 /// One of the @link comparison_functors comparison functors@endlink.
485 template<>
486 struct equal_to<void>
487 {
488 template <typename _Tp, typename _Up>
489 constexpr auto
490 operator()(_Tp&& __t, _Up&& __u) const
491 noexcept(noexcept(std::forward<_Tp>(__t) == std::forward<_Up>(__u)))
492 -> decltype(std::forward<_Tp>(__t) == std::forward<_Up>(__u))
493 { return std::forward<_Tp>(__t) == std::forward<_Up>(__u); }
494
495 typedef __is_transparent is_transparent;
496 };
497
498 /// One of the @link comparison_functors comparison functors@endlink.
499 template<>
500 struct not_equal_to<void>
501 {
502 template <typename _Tp, typename _Up>
503 constexpr auto
504 operator()(_Tp&& __t, _Up&& __u) const
505 noexcept(noexcept(std::forward<_Tp>(__t) != std::forward<_Up>(__u)))
506 -> decltype(std::forward<_Tp>(__t) != std::forward<_Up>(__u))
507 { return std::forward<_Tp>(__t) != std::forward<_Up>(__u); }
508
509 typedef __is_transparent is_transparent;
510 };
511
512 /// One of the @link comparison_functors comparison functors@endlink.
513 template<>
514 struct greater<void>
515 {
516 template <typename _Tp, typename _Up>
517 constexpr auto
518 operator()(_Tp&& __t, _Up&& __u) const
519 noexcept(noexcept(std::forward<_Tp>(__t) > std::forward<_Up>(__u)))
520 -> decltype(std::forward<_Tp>(__t) > std::forward<_Up>(__u))
521 {
522 return _S_cmp(std::forward<_Tp>(__t), std::forward<_Up>(__u),
523 __ptr_cmp<_Tp, _Up>{});
524 }
525
526 template<typename _Tp, typename _Up>
527 constexpr bool
528 operator()(_Tp* __t, _Up* __u) const noexcept
529 { return greater<common_type_t<_Tp*, _Up*>>{}(__t, __u); }
530
531 typedef __is_transparent is_transparent;
532
533 private:
534 template <typename _Tp, typename _Up>
535 static constexpr decltype(auto)
536 _S_cmp(_Tp&& __t, _Up&& __u, false_type)
537 { return std::forward<_Tp>(__t) > std::forward<_Up>(__u); }
538
539 template <typename _Tp, typename _Up>
540 static constexpr bool
541 _S_cmp(_Tp&& __t, _Up&& __u, true_type) noexcept
542 {
543 return greater<const volatile void*>{}(
544 static_cast<const volatile void*>(std::forward<_Tp>(__t)),
545 static_cast<const volatile void*>(std::forward<_Up>(__u)));
546 }
547
548 // True if there is no viable operator> member function.
549 template<typename _Tp, typename _Up, typename = void>
550 struct __not_overloaded2 : true_type { };
551
552 // False if we can call T.operator>(U)
553 template<typename _Tp, typename _Up>
554 struct __not_overloaded2<_Tp, _Up, __void_t<
555 decltype(std::declval<_Tp>().operator>(std::declval<_Up>()))>>
556 : false_type { };
557
558 // True if there is no overloaded operator> for these operands.
559 template<typename _Tp, typename _Up, typename = void>
560 struct __not_overloaded : __not_overloaded2<_Tp, _Up> { };
561
562 // False if we can call operator>(T,U)
563 template<typename _Tp, typename _Up>
564 struct __not_overloaded<_Tp, _Up, __void_t<
565 decltype(operator>(std::declval<_Tp>(), std::declval<_Up>()))>>
566 : false_type { };
567
568 template<typename _Tp, typename _Up>
569 using __ptr_cmp = __and_<__not_overloaded<_Tp, _Up>,
570 is_convertible<_Tp, const volatile void*>,
571 is_convertible<_Up, const volatile void*>>;
572 };
573
574 /// One of the @link comparison_functors comparison functors@endlink.
575 template<>
576 struct less<void>
577 {
578 template <typename _Tp, typename _Up>
579 constexpr auto
580 operator()(_Tp&& __t, _Up&& __u) const
581 noexcept(noexcept(std::forward<_Tp>(__t) < std::forward<_Up>(__u)))
582 -> decltype(std::forward<_Tp>(__t) < std::forward<_Up>(__u))
583 {
584 return _S_cmp(std::forward<_Tp>(__t), std::forward<_Up>(__u),
585 __ptr_cmp<_Tp, _Up>{});
586 }
587
588 template<typename _Tp, typename _Up>
589 constexpr bool
590 operator()(_Tp* __t, _Up* __u) const noexcept
591 { return less<common_type_t<_Tp*, _Up*>>{}(__t, __u); }
592
593 typedef __is_transparent is_transparent;
594
595 private:
596 template <typename _Tp, typename _Up>
597 static constexpr decltype(auto)
598 _S_cmp(_Tp&& __t, _Up&& __u, false_type)
599 { return std::forward<_Tp>(__t) < std::forward<_Up>(__u); }
600
601 template <typename _Tp, typename _Up>
602 static constexpr bool
603 _S_cmp(_Tp&& __t, _Up&& __u, true_type) noexcept
604 {
605 return less<const volatile void*>{}(
606 static_cast<const volatile void*>(std::forward<_Tp>(__t)),
607 static_cast<const volatile void*>(std::forward<_Up>(__u)));
608 }
609
610 // True if there is no viable operator< member function.
611 template<typename _Tp, typename _Up, typename = void>
612 struct __not_overloaded2 : true_type { };
613
614 // False if we can call T.operator<(U)
615 template<typename _Tp, typename _Up>
616 struct __not_overloaded2<_Tp, _Up, __void_t<
617 decltype(std::declval<_Tp>().operator<(std::declval<_Up>()))>>
618 : false_type { };
619
620 // True if there is no overloaded operator< for these operands.
621 template<typename _Tp, typename _Up, typename = void>
622 struct __not_overloaded : __not_overloaded2<_Tp, _Up> { };
623
624 // False if we can call operator<(T,U)
625 template<typename _Tp, typename _Up>
626 struct __not_overloaded<_Tp, _Up, __void_t<
627 decltype(operator<(std::declval<_Tp>(), std::declval<_Up>()))>>
628 : false_type { };
629
630 template<typename _Tp, typename _Up>
631 using __ptr_cmp = __and_<__not_overloaded<_Tp, _Up>,
632 is_convertible<_Tp, const volatile void*>,
633 is_convertible<_Up, const volatile void*>>;
634 };
635
636 /// One of the @link comparison_functors comparison functors@endlink.
637 template<>
638 struct greater_equal<void>
639 {
640 template <typename _Tp, typename _Up>
641 constexpr auto
642 operator()(_Tp&& __t, _Up&& __u) const
643 noexcept(noexcept(std::forward<_Tp>(__t) >= std::forward<_Up>(__u)))
644 -> decltype(std::forward<_Tp>(__t) >= std::forward<_Up>(__u))
645 {
646 return _S_cmp(std::forward<_Tp>(__t), std::forward<_Up>(__u),
647 __ptr_cmp<_Tp, _Up>{});
648 }
649
650 template<typename _Tp, typename _Up>
651 constexpr bool
652 operator()(_Tp* __t, _Up* __u) const noexcept
653 { return greater_equal<common_type_t<_Tp*, _Up*>>{}(__t, __u); }
654
655 typedef __is_transparent is_transparent;
656
657 private:
658 template <typename _Tp, typename _Up>
659 static constexpr decltype(auto)
660 _S_cmp(_Tp&& __t, _Up&& __u, false_type)
661 { return std::forward<_Tp>(__t) >= std::forward<_Up>(__u); }
662
663 template <typename _Tp, typename _Up>
664 static constexpr bool
665 _S_cmp(_Tp&& __t, _Up&& __u, true_type) noexcept
666 {
667 return greater_equal<const volatile void*>{}(
668 static_cast<const volatile void*>(std::forward<_Tp>(__t)),
669 static_cast<const volatile void*>(std::forward<_Up>(__u)));
670 }
671
672 // True if there is no viable operator>= member function.
673 template<typename _Tp, typename _Up, typename = void>
674 struct __not_overloaded2 : true_type { };
675
676 // False if we can call T.operator>=(U)
677 template<typename _Tp, typename _Up>
678 struct __not_overloaded2<_Tp, _Up, __void_t<
679 decltype(std::declval<_Tp>().operator>=(std::declval<_Up>()))>>
680 : false_type { };
681
682 // True if there is no overloaded operator>= for these operands.
683 template<typename _Tp, typename _Up, typename = void>
684 struct __not_overloaded : __not_overloaded2<_Tp, _Up> { };
685
686 // False if we can call operator>=(T,U)
687 template<typename _Tp, typename _Up>
688 struct __not_overloaded<_Tp, _Up, __void_t<
689 decltype(operator>=(std::declval<_Tp>(), std::declval<_Up>()))>>
690 : false_type { };
691
692 template<typename _Tp, typename _Up>
693 using __ptr_cmp = __and_<__not_overloaded<_Tp, _Up>,
694 is_convertible<_Tp, const volatile void*>,
695 is_convertible<_Up, const volatile void*>>;
696 };
697
698 /// One of the @link comparison_functors comparison functors@endlink.
699 template<>
700 struct less_equal<void>
701 {
702 template <typename _Tp, typename _Up>
703 constexpr auto
704 operator()(_Tp&& __t, _Up&& __u) const
705 noexcept(noexcept(std::forward<_Tp>(__t) <= std::forward<_Up>(__u)))
706 -> decltype(std::forward<_Tp>(__t) <= std::forward<_Up>(__u))
707 {
708 return _S_cmp(std::forward<_Tp>(__t), std::forward<_Up>(__u),
709 __ptr_cmp<_Tp, _Up>{});
710 }
711
712 template<typename _Tp, typename _Up>
713 constexpr bool
714 operator()(_Tp* __t, _Up* __u) const noexcept
715 { return less_equal<common_type_t<_Tp*, _Up*>>{}(__t, __u); }
716
717 typedef __is_transparent is_transparent;
718
719 private:
720 template <typename _Tp, typename _Up>
721 static constexpr decltype(auto)
722 _S_cmp(_Tp&& __t, _Up&& __u, false_type)
723 { return std::forward<_Tp>(__t) <= std::forward<_Up>(__u); }
724
725 template <typename _Tp, typename _Up>
726 static constexpr bool
727 _S_cmp(_Tp&& __t, _Up&& __u, true_type) noexcept
728 {
729 return less_equal<const volatile void*>{}(
730 static_cast<const volatile void*>(std::forward<_Tp>(__t)),
731 static_cast<const volatile void*>(std::forward<_Up>(__u)));
732 }
733
734 // True if there is no viable operator<= member function.
735 template<typename _Tp, typename _Up, typename = void>
736 struct __not_overloaded2 : true_type { };
737
738 // False if we can call T.operator<=(U)
739 template<typename _Tp, typename _Up>
740 struct __not_overloaded2<_Tp, _Up, __void_t<
741 decltype(std::declval<_Tp>().operator<=(std::declval<_Up>()))>>
742 : false_type { };
743
744 // True if there is no overloaded operator<= for these operands.
745 template<typename _Tp, typename _Up, typename = void>
746 struct __not_overloaded : __not_overloaded2<_Tp, _Up> { };
747
748 // False if we can call operator<=(T,U)
749 template<typename _Tp, typename _Up>
750 struct __not_overloaded<_Tp, _Up, __void_t<
751 decltype(operator<=(std::declval<_Tp>(), std::declval<_Up>()))>>
752 : false_type { };
753
754 template<typename _Tp, typename _Up>
755 using __ptr_cmp = __and_<__not_overloaded<_Tp, _Up>,
756 is_convertible<_Tp, const volatile void*>,
757 is_convertible<_Up, const volatile void*>>;
758 };
759 #endif // C++14
760 /** @} */
761
762 // 20.3.4 logical operations
763 /** @defgroup logical_functors Boolean Operations Classes
764 * @ingroup functors
765 *
766 * The library provides function objects for the logical operations:
767 * `&&`, `||`, and `!`.
768 *
769 * @{
770 */
771 #if __cplusplus > 201103L
772 template<typename _Tp = void>
773 struct logical_and;
774
775 template<typename _Tp = void>
776 struct logical_or;
777
778 template<typename _Tp = void>
779 struct logical_not;
780 #endif
781
782 /// One of the @link logical_functors Boolean operations functors@endlink.
783 template<typename _Tp>
784 struct logical_and : public binary_function<_Tp, _Tp, bool>
785 {
786 _GLIBCXX14_CONSTEXPR
787 bool
788 operator()(const _Tp& __x, const _Tp& __y) const
789 { return __x && __y; }
790 };
791
792 /// One of the @link logical_functors Boolean operations functors@endlink.
793 template<typename _Tp>
794 struct logical_or : public binary_function<_Tp, _Tp, bool>
795 {
796 _GLIBCXX14_CONSTEXPR
797 bool
798 operator()(const _Tp& __x, const _Tp& __y) const
799 { return __x || __y; }
800 };
801
802 /// One of the @link logical_functors Boolean operations functors@endlink.
803 template<typename _Tp>
804 struct logical_not : public unary_function<_Tp, bool>
805 {
806 _GLIBCXX14_CONSTEXPR
807 bool
808 operator()(const _Tp& __x) const
809 { return !__x; }
810 };
811
812 #if __cplusplus > 201103L
813 /// One of the @link logical_functors Boolean operations functors@endlink.
814 template<>
815 struct logical_and<void>
816 {
817 template <typename _Tp, typename _Up>
818 _GLIBCXX14_CONSTEXPR
819 auto
820 operator()(_Tp&& __t, _Up&& __u) const
821 noexcept(noexcept(std::forward<_Tp>(__t) && std::forward<_Up>(__u)))
822 -> decltype(std::forward<_Tp>(__t) && std::forward<_Up>(__u))
823 { return std::forward<_Tp>(__t) && std::forward<_Up>(__u); }
824
825 typedef __is_transparent is_transparent;
826 };
827
828 /// One of the @link logical_functors Boolean operations functors@endlink.
829 template<>
830 struct logical_or<void>
831 {
832 template <typename _Tp, typename _Up>
833 _GLIBCXX14_CONSTEXPR
834 auto
835 operator()(_Tp&& __t, _Up&& __u) const
836 noexcept(noexcept(std::forward<_Tp>(__t) || std::forward<_Up>(__u)))
837 -> decltype(std::forward<_Tp>(__t) || std::forward<_Up>(__u))
838 { return std::forward<_Tp>(__t) || std::forward<_Up>(__u); }
839
840 typedef __is_transparent is_transparent;
841 };
842
843 /// One of the @link logical_functors Boolean operations functors@endlink.
844 template<>
845 struct logical_not<void>
846 {
847 template <typename _Tp>
848 _GLIBCXX14_CONSTEXPR
849 auto
850 operator()(_Tp&& __t) const
851 noexcept(noexcept(!std::forward<_Tp>(__t)))
852 -> decltype(!std::forward<_Tp>(__t))
853 { return !std::forward<_Tp>(__t); }
854
855 typedef __is_transparent is_transparent;
856 };
857 #endif
858 /** @} */
859
860 #if __cplusplus > 201103L
861 template<typename _Tp = void>
862 struct bit_and;
863
864 template<typename _Tp = void>
865 struct bit_or;
866
867 template<typename _Tp = void>
868 struct bit_xor;
869
870 template<typename _Tp = void>
871 struct bit_not;
872 #endif
873
874 // _GLIBCXX_RESOLVE_LIB_DEFECTS
875 // DR 660. Missing Bitwise Operations.
876 template<typename _Tp>
877 struct bit_and : public binary_function<_Tp, _Tp, _Tp>
878 {
879 _GLIBCXX14_CONSTEXPR
880 _Tp
881 operator()(const _Tp& __x, const _Tp& __y) const
882 { return __x & __y; }
883 };
884
885 template<typename _Tp>
886 struct bit_or : public binary_function<_Tp, _Tp, _Tp>
887 {
888 _GLIBCXX14_CONSTEXPR
889 _Tp
890 operator()(const _Tp& __x, const _Tp& __y) const
891 { return __x | __y; }
892 };
893
894 template<typename _Tp>
895 struct bit_xor : public binary_function<_Tp, _Tp, _Tp>
896 {
897 _GLIBCXX14_CONSTEXPR
898 _Tp
899 operator()(const _Tp& __x, const _Tp& __y) const
900 { return __x ^ __y; }
901 };
902
903 template<typename _Tp>
904 struct bit_not : public unary_function<_Tp, _Tp>
905 {
906 _GLIBCXX14_CONSTEXPR
907 _Tp
908 operator()(const _Tp& __x) const
909 { return ~__x; }
910 };
911
912 #if __cplusplus > 201103L
913 template <>
914 struct bit_and<void>
915 {
916 template <typename _Tp, typename _Up>
917 _GLIBCXX14_CONSTEXPR
918 auto
919 operator()(_Tp&& __t, _Up&& __u) const
920 noexcept(noexcept(std::forward<_Tp>(__t) & std::forward<_Up>(__u)))
921 -> decltype(std::forward<_Tp>(__t) & std::forward<_Up>(__u))
922 { return std::forward<_Tp>(__t) & std::forward<_Up>(__u); }
923
924 typedef __is_transparent is_transparent;
925 };
926
927 template <>
928 struct bit_or<void>
929 {
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); }
937
938 typedef __is_transparent is_transparent;
939 };
940
941 template <>
942 struct bit_xor<void>
943 {
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); }
951
952 typedef __is_transparent is_transparent;
953 };
954
955 template <>
956 struct bit_not<void>
957 {
958 template <typename _Tp>
959 _GLIBCXX14_CONSTEXPR
960 auto
961 operator()(_Tp&& __t) const
962 noexcept(noexcept(~std::forward<_Tp>(__t)))
963 -> decltype(~std::forward<_Tp>(__t))
964 { return ~std::forward<_Tp>(__t); }
965
966 typedef __is_transparent is_transparent;
967 };
968 #endif
969
970 // 20.3.5 negators
971 /** @defgroup negators Negators
972 * @ingroup functors
973 *
974 * The function templates `not1` and `not2` are function object adaptors,
975 * which each take a predicate functor and wrap it in an instance of
976 * `unary_negate` or `binary_negate`, respectively. Those classes are
977 * functors whose `operator()` evaluates the wrapped predicate function
978 * and then returns the negation of the result.
979 *
980 * For example, given a vector of integers and a trivial predicate,
981 * \code
982 * struct IntGreaterThanThree
983 * : public std::unary_function<int, bool>
984 * {
985 * bool operator() (int x) const { return x > 3; }
986 * };
987 *
988 * std::find_if (v.begin(), v.end(), not1(IntGreaterThanThree()));
989 * \endcode
990 * The call to `find_if` will locate the first index (i) of `v` for which
991 * `!(v[i] > 3)` is true.
992 *
993 * The not1/unary_negate combination works on predicates taking a single
994 * argument. The not2/binary_negate combination works on predicates taking
995 * two arguments.
996 *
997 * @deprecated Deprecated in C++17, no longer in the standard since C++20.
998 * Use `not_fn` instead.
999 *
1000 * @{
1001 */
1002 /// One of the @link negators negation functors@endlink.
1003 template<typename _Predicate>
1004 class unary_negate
1005 : public unary_function<typename _Predicate::argument_type, bool>
1006 {
1007 protected:
1008 _Predicate _M_pred;
1009
1010 public:
1011 _GLIBCXX14_CONSTEXPR
1012 explicit
1013 unary_negate(const _Predicate& __x) : _M_pred(__x) { }
1014
1015 _GLIBCXX14_CONSTEXPR
1016 bool
1017 operator()(const typename _Predicate::argument_type& __x) const
1018 { return !_M_pred(__x); }
1019 };
1020
1021 /// One of the @link negators negation functors@endlink.
1022 template<typename _Predicate>
1023 _GLIBCXX14_CONSTEXPR
1024 inline unary_negate<_Predicate>
1025 not1(const _Predicate& __pred)
1026 { return unary_negate<_Predicate>(__pred); }
1027
1028 /// One of the @link negators negation functors@endlink.
1029 template<typename _Predicate>
1030 class binary_negate
1031 : public binary_function<typename _Predicate::first_argument_type,
1032 typename _Predicate::second_argument_type, bool>
1033 {
1034 protected:
1035 _Predicate _M_pred;
1036
1037 public:
1038 _GLIBCXX14_CONSTEXPR
1039 explicit
1040 binary_negate(const _Predicate& __x) : _M_pred(__x) { }
1041
1042 _GLIBCXX14_CONSTEXPR
1043 bool
1044 operator()(const typename _Predicate::first_argument_type& __x,
1045 const typename _Predicate::second_argument_type& __y) const
1046 { return !_M_pred(__x, __y); }
1047 };
1048
1049 /// One of the @link negators negation functors@endlink.
1050 template<typename _Predicate>
1051 _GLIBCXX14_CONSTEXPR
1052 inline binary_negate<_Predicate>
1053 not2(const _Predicate& __pred)
1054 { return binary_negate<_Predicate>(__pred); }
1055 /** @} */
1056
1057 // 20.3.7 adaptors pointers functions
1058 /** @defgroup pointer_adaptors Adaptors for pointers to functions
1059 * @ingroup functors
1060 *
1061 * The advantage of function objects over pointers to functions is that
1062 * the objects in the standard library declare nested typedefs describing
1063 * their argument and result types with uniform names (e.g., `result_type`
1064 * from the base classes `unary_function` and `binary_function`).
1065 * Sometimes those typedefs are required, not just optional.
1066 *
1067 * Adaptors are provided to turn pointers to unary (single-argument) and
1068 * binary (double-argument) functions into function objects. The
1069 * long-winded functor `pointer_to_unary_function` is constructed with a
1070 * function pointer `f`, and its `operator()` called with argument `x`
1071 * returns `f(x)`. The functor `pointer_to_binary_function` does the same
1072 * thing, but with a double-argument `f` and `operator()`.
1073 *
1074 * The function `ptr_fun` takes a pointer-to-function `f` and constructs
1075 * an instance of the appropriate functor.
1076 *
1077 * @deprecated Deprecated in C++11, no longer in the standard since C++17.
1078 *
1079 * @{
1080 */
1081 /// One of the @link pointer_adaptors adaptors for function pointers@endlink.
1082 template<typename _Arg, typename _Result>
1083 class pointer_to_unary_function : public unary_function<_Arg, _Result>
1084 {
1085 protected:
1086 _Result (*_M_ptr)(_Arg);
1087
1088 public:
1089 pointer_to_unary_function() { }
1090
1091 explicit
1092 pointer_to_unary_function(_Result (*__x)(_Arg))
1093 : _M_ptr(__x) { }
1094
1095 _Result
1096 operator()(_Arg __x) const
1097 { return _M_ptr(__x); }
1098 };
1099
1100 /// One of the @link pointer_adaptors adaptors for function pointers@endlink.
1101 template<typename _Arg, typename _Result>
1102 inline pointer_to_unary_function<_Arg, _Result>
1103 ptr_fun(_Result (*__x)(_Arg))
1104 { return pointer_to_unary_function<_Arg, _Result>(__x); }
1105
1106 /// One of the @link pointer_adaptors adaptors for function pointers@endlink.
1107 template<typename _Arg1, typename _Arg2, typename _Result>
1108 class pointer_to_binary_function
1109 : public binary_function<_Arg1, _Arg2, _Result>
1110 {
1111 protected:
1112 _Result (*_M_ptr)(_Arg1, _Arg2);
1113
1114 public:
1115 pointer_to_binary_function() { }
1116
1117 explicit
1118 pointer_to_binary_function(_Result (*__x)(_Arg1, _Arg2))
1119 : _M_ptr(__x) { }
1120
1121 _Result
1122 operator()(_Arg1 __x, _Arg2 __y) const
1123 { return _M_ptr(__x, __y); }
1124 };
1125
1126 /// One of the @link pointer_adaptors adaptors for function pointers@endlink.
1127 template<typename _Arg1, typename _Arg2, typename _Result>
1128 inline pointer_to_binary_function<_Arg1, _Arg2, _Result>
1129 ptr_fun(_Result (*__x)(_Arg1, _Arg2))
1130 { return pointer_to_binary_function<_Arg1, _Arg2, _Result>(__x); }
1131 /** @} */
1132
1133 template<typename _Tp>
1134 struct _Identity
1135 : public unary_function<_Tp, _Tp>
1136 {
1137 _Tp&
1138 operator()(_Tp& __x) const
1139 { return __x; }
1140
1141 const _Tp&
1142 operator()(const _Tp& __x) const
1143 { return __x; }
1144 };
1145
1146 // Partial specialization, avoids confusing errors in e.g. std::set<const T>.
1147 template<typename _Tp> struct _Identity<const _Tp> : _Identity<_Tp> { };
1148
1149 template<typename _Pair>
1150 struct _Select1st
1151 : public unary_function<_Pair, typename _Pair::first_type>
1152 {
1153 typename _Pair::first_type&
1154 operator()(_Pair& __x) const
1155 { return __x.first; }
1156
1157 const typename _Pair::first_type&
1158 operator()(const _Pair& __x) const
1159 { return __x.first; }
1160
1161 #if __cplusplus >= 201103L
1162 template<typename _Pair2>
1163 typename _Pair2::first_type&
1164 operator()(_Pair2& __x) const
1165 { return __x.first; }
1166
1167 template<typename _Pair2>
1168 const typename _Pair2::first_type&
1169 operator()(const _Pair2& __x) const
1170 { return __x.first; }
1171 #endif
1172 };
1173
1174 template<typename _Pair>
1175 struct _Select2nd
1176 : public unary_function<_Pair, typename _Pair::second_type>
1177 {
1178 typename _Pair::second_type&
1179 operator()(_Pair& __x) const
1180 { return __x.second; }
1181
1182 const typename _Pair::second_type&
1183 operator()(const _Pair& __x) const
1184 { return __x.second; }
1185 };
1186
1187 // 20.3.8 adaptors pointers members
1188 /** @defgroup ptrmem_adaptors Adaptors for pointers to members
1189 * @ingroup functors
1190 *
1191 * There are a total of 8 = 2^3 function objects in this family.
1192 * (1) Member functions taking no arguments vs member functions taking
1193 * one argument.
1194 * (2) Call through pointer vs call through reference.
1195 * (3) Const vs non-const member function.
1196 *
1197 * All of this complexity is in the function objects themselves. You can
1198 * ignore it by using the helper function `mem_fun` and `mem_fun_ref`,
1199 * which create whichever type of adaptor is appropriate.
1200 *
1201 * @deprecated Deprecated in C++11, no longer in the standard since C++17.
1202 * Use `mem_fn` instead.
1203 *
1204 * @{
1205 */
1206 /// One of the @link ptrmem_adaptors adaptors for member pointers@endlink.
1207 template<typename _Ret, typename _Tp>
1208 class mem_fun_t : public unary_function<_Tp*, _Ret>
1209 {
1210 public:
1211 explicit
1212 mem_fun_t(_Ret (_Tp::*__pf)())
1213 : _M_f(__pf) { }
1214
1215 _Ret
1216 operator()(_Tp* __p) const
1217 { return (__p->*_M_f)(); }
1218
1219 private:
1220 _Ret (_Tp::*_M_f)();
1221 };
1222
1223 /// One of the @link ptrmem_adaptors adaptors for member pointers@endlink.
1224 template<typename _Ret, typename _Tp>
1225 class const_mem_fun_t : public unary_function<const _Tp*, _Ret>
1226 {
1227 public:
1228 explicit
1229 const_mem_fun_t(_Ret (_Tp::*__pf)() const)
1230 : _M_f(__pf) { }
1231
1232 _Ret
1233 operator()(const _Tp* __p) const
1234 { return (__p->*_M_f)(); }
1235
1236 private:
1237 _Ret (_Tp::*_M_f)() const;
1238 };
1239
1240 /// One of the @link ptrmem_adaptors adaptors for member pointers@endlink.
1241 template<typename _Ret, typename _Tp>
1242 class mem_fun_ref_t : public unary_function<_Tp, _Ret>
1243 {
1244 public:
1245 explicit
1246 mem_fun_ref_t(_Ret (_Tp::*__pf)())
1247 : _M_f(__pf) { }
1248
1249 _Ret
1250 operator()(_Tp& __r) const
1251 { return (__r.*_M_f)(); }
1252
1253 private:
1254 _Ret (_Tp::*_M_f)();
1255 };
1256
1257 /// One of the @link ptrmem_adaptors adaptors for member pointers@endlink.
1258 template<typename _Ret, typename _Tp>
1259 class const_mem_fun_ref_t : public unary_function<_Tp, _Ret>
1260 {
1261 public:
1262 explicit
1263 const_mem_fun_ref_t(_Ret (_Tp::*__pf)() const)
1264 : _M_f(__pf) { }
1265
1266 _Ret
1267 operator()(const _Tp& __r) const
1268 { return (__r.*_M_f)(); }
1269
1270 private:
1271 _Ret (_Tp::*_M_f)() const;
1272 };
1273
1274 /// One of the @link ptrmem_adaptors adaptors for member pointers@endlink.
1275 template<typename _Ret, typename _Tp, typename _Arg>
1276 class mem_fun1_t : public binary_function<_Tp*, _Arg, _Ret>
1277 {
1278 public:
1279 explicit
1280 mem_fun1_t(_Ret (_Tp::*__pf)(_Arg))
1281 : _M_f(__pf) { }
1282
1283 _Ret
1284 operator()(_Tp* __p, _Arg __x) const
1285 { return (__p->*_M_f)(__x); }
1286
1287 private:
1288 _Ret (_Tp::*_M_f)(_Arg);
1289 };
1290
1291 /// One of the @link ptrmem_adaptors adaptors for member pointers@endlink.
1292 template<typename _Ret, typename _Tp, typename _Arg>
1293 class const_mem_fun1_t : public binary_function<const _Tp*, _Arg, _Ret>
1294 {
1295 public:
1296 explicit
1297 const_mem_fun1_t(_Ret (_Tp::*__pf)(_Arg) const)
1298 : _M_f(__pf) { }
1299
1300 _Ret
1301 operator()(const _Tp* __p, _Arg __x) const
1302 { return (__p->*_M_f)(__x); }
1303
1304 private:
1305 _Ret (_Tp::*_M_f)(_Arg) const;
1306 };
1307
1308 /// One of the @link ptrmem_adaptors adaptors for member pointers@endlink.
1309 template<typename _Ret, typename _Tp, typename _Arg>
1310 class mem_fun1_ref_t : public binary_function<_Tp, _Arg, _Ret>
1311 {
1312 public:
1313 explicit
1314 mem_fun1_ref_t(_Ret (_Tp::*__pf)(_Arg))
1315 : _M_f(__pf) { }
1316
1317 _Ret
1318 operator()(_Tp& __r, _Arg __x) const
1319 { return (__r.*_M_f)(__x); }
1320
1321 private:
1322 _Ret (_Tp::*_M_f)(_Arg);
1323 };
1324
1325 /// One of the @link ptrmem_adaptors adaptors for member pointers@endlink.
1326 template<typename _Ret, typename _Tp, typename _Arg>
1327 class const_mem_fun1_ref_t : public binary_function<_Tp, _Arg, _Ret>
1328 {
1329 public:
1330 explicit
1331 const_mem_fun1_ref_t(_Ret (_Tp::*__pf)(_Arg) const)
1332 : _M_f(__pf) { }
1333
1334 _Ret
1335 operator()(const _Tp& __r, _Arg __x) const
1336 { return (__r.*_M_f)(__x); }
1337
1338 private:
1339 _Ret (_Tp::*_M_f)(_Arg) const;
1340 };
1341
1342 // Mem_fun adaptor helper functions. There are only two:
1343 // mem_fun and mem_fun_ref.
1344 template<typename _Ret, typename _Tp>
1345 inline mem_fun_t<_Ret, _Tp>
1346 mem_fun(_Ret (_Tp::*__f)())
1347 { return mem_fun_t<_Ret, _Tp>(__f); }
1348
1349 template<typename _Ret, typename _Tp>
1350 inline const_mem_fun_t<_Ret, _Tp>
1351 mem_fun(_Ret (_Tp::*__f)() const)
1352 { return const_mem_fun_t<_Ret, _Tp>(__f); }
1353
1354 template<typename _Ret, typename _Tp>
1355 inline mem_fun_ref_t<_Ret, _Tp>
1356 mem_fun_ref(_Ret (_Tp::*__f)())
1357 { return mem_fun_ref_t<_Ret, _Tp>(__f); }
1358
1359 template<typename _Ret, typename _Tp>
1360 inline const_mem_fun_ref_t<_Ret, _Tp>
1361 mem_fun_ref(_Ret (_Tp::*__f)() const)
1362 { return const_mem_fun_ref_t<_Ret, _Tp>(__f); }
1363
1364 template<typename _Ret, typename _Tp, typename _Arg>
1365 inline mem_fun1_t<_Ret, _Tp, _Arg>
1366 mem_fun(_Ret (_Tp::*__f)(_Arg))
1367 { return mem_fun1_t<_Ret, _Tp, _Arg>(__f); }
1368
1369 template<typename _Ret, typename _Tp, typename _Arg>
1370 inline const_mem_fun1_t<_Ret, _Tp, _Arg>
1371 mem_fun(_Ret (_Tp::*__f)(_Arg) const)
1372 { return const_mem_fun1_t<_Ret, _Tp, _Arg>(__f); }
1373
1374 template<typename _Ret, typename _Tp, typename _Arg>
1375 inline mem_fun1_ref_t<_Ret, _Tp, _Arg>
1376 mem_fun_ref(_Ret (_Tp::*__f)(_Arg))
1377 { return mem_fun1_ref_t<_Ret, _Tp, _Arg>(__f); }
1378
1379 template<typename _Ret, typename _Tp, typename _Arg>
1380 inline const_mem_fun1_ref_t<_Ret, _Tp, _Arg>
1381 mem_fun_ref(_Ret (_Tp::*__f)(_Arg) const)
1382 { return const_mem_fun1_ref_t<_Ret, _Tp, _Arg>(__f); }
1383
1384 /** @} */
1385
1386 #if __cplusplus >= 201402L
1387 template<typename _Func, typename _SfinaeType, typename = __void_t<>>
1388 struct __has_is_transparent
1389 { };
1390
1391 template<typename _Func, typename _SfinaeType>
1392 struct __has_is_transparent<_Func, _SfinaeType,
1393 __void_t<typename _Func::is_transparent>>
1394 { typedef void type; };
1395
1396 template<typename _Func, typename _SfinaeType>
1397 using __has_is_transparent_t
1398 = typename __has_is_transparent<_Func, _SfinaeType>::type;
1399 #endif
1400
1401 _GLIBCXX_END_NAMESPACE_VERSION
1402 } // namespace
1403
1404 #if (__cplusplus < 201103L) || _GLIBCXX_USE_DEPRECATED
1405 # include <backward/binders.h>
1406 #endif
1407
1408 #endif /* _STL_FUNCTION_H */