]>
Commit | Line | Data |
---|---|---|
42526146 PE |
1 | // Functor implementations -*- C++ -*- |
2 | ||
6441eb6d | 3 | // Copyright (C) 2001-2025 Free Software Foundation, Inc. |
42526146 PE |
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 | |
748086b7 | 8 | // Free Software Foundation; either version 3, or (at your option) |
42526146 PE |
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 | ||
748086b7 JJ |
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. | |
42526146 | 19 | |
748086b7 JJ |
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/>. | |
42526146 | 24 | |
725dc051 BK |
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 | ||
f910786b | 51 | /** @file bits/stl_function.h |
729e3d3f | 52 | * This is an internal header file, included by other library headers. |
f910786b | 53 | * Do not attempt to use it directly. @headername{functional} |
725dc051 BK |
54 | */ |
55 | ||
046d30f4 PC |
56 | #ifndef _STL_FUNCTION_H |
57 | #define _STL_FUNCTION_H 1 | |
725dc051 | 58 | |
d081231a JW |
59 | #if __cplusplus > 201103L |
60 | #include <bits/move.h> | |
61 | #endif | |
62 | ||
12ffa228 BK |
63 | namespace std _GLIBCXX_VISIBILITY(default) |
64 | { | |
65 | _GLIBCXX_BEGIN_NAMESPACE_VERSION | |
3cbc7af0 | 66 | |
f6592a9e | 67 | // 20.3.1 base classes |
aac2878e | 68 | /** @defgroup functors Function Objects |
828176ba | 69 | * @ingroup utilities |
aac2878e | 70 | * |
828176ba | 71 | * Function objects, or _functors_, are objects with an `operator()` |
f6592a9e PC |
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 | |
828176ba | 76 | * refer to _functors_, then, generally we include function pointers in |
f6592a9e PC |
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 | |
828176ba JW |
83 | * by-element addition of two vectors `a` and `b` containing `double`, |
84 | * and put the result in `a`, use | |
f6592a9e PC |
85 | * \code |
86 | * transform (a.begin(), a.end(), b.begin(), a.begin(), plus<double>()); | |
87 | * \endcode | |
828176ba | 88 | * To negate every element in `a`, use |
f6592a9e PC |
89 | * \code |
90 | * transform(a.begin(), a.end(), a.begin(), negate<double>()); | |
91 | * \endcode | |
828176ba | 92 | * The addition and negation functions will usually be inlined directly. |
f6592a9e | 93 | * |
828176ba JW |
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. | |
f6592a9e PC |
108 | * |
109 | * @{ | |
110 | */ | |
828176ba | 111 | |
f6592a9e | 112 | /** |
828176ba JW |
113 | * Helper for defining adaptable unary function objects. |
114 | * @deprecated Deprecated in C++11, no longer in the standard since C++17. | |
f6592a9e | 115 | */ |
bd1a56a0 | 116 | template<typename _Arg, typename _Result> |
f6592a9e PC |
117 | struct unary_function |
118 | { | |
f910786b | 119 | /// @c argument_type is the type of the argument |
45ab93d9 | 120 | typedef _Arg argument_type; |
f6592a9e | 121 | |
f910786b | 122 | /// @c result_type is the return type |
45ab93d9 | 123 | typedef _Result result_type; |
de196e5d | 124 | } _GLIBCXX11_DEPRECATED; |
f6592a9e PC |
125 | |
126 | /** | |
828176ba JW |
127 | * Helper for defining adaptable binary function objects. |
128 | * @deprecated Deprecated in C++11, no longer in the standard since C++17. | |
f6592a9e | 129 | */ |
bd1a56a0 | 130 | template<typename _Arg1, typename _Arg2, typename _Result> |
f6592a9e PC |
131 | struct binary_function |
132 | { | |
f910786b | 133 | /// @c first_argument_type is the type of the first argument |
45ab93d9 | 134 | typedef _Arg1 first_argument_type; |
f6592a9e | 135 | |
f910786b BK |
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; | |
de196e5d | 141 | } _GLIBCXX11_DEPRECATED; |
f6592a9e PC |
142 | /** @} */ |
143 | ||
144 | // 20.3.2 arithmetic | |
828176ba JW |
145 | |
146 | /** @defgroup arithmetic_functors Arithmetic Function Object Classes | |
147 | * @ingroup functors | |
aac2878e | 148 | * |
828176ba JW |
149 | * The library provides function objects for basic arithmetic operations. |
150 | * See the documentation for @link functors function objects @endlink | |
65be6ddd | 151 | * for examples of their use. |
f6592a9e PC |
152 | * |
153 | * @{ | |
154 | */ | |
d081231a | 155 | |
7ffa63df | 156 | #if __glibcxx_transparent_operators // C++ >= 14 |
d081231a JW |
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 | ||
de196e5d JW |
178 | // Ignore warnings about unary_function and binary_function. |
179 | #pragma GCC diagnostic push | |
180 | #pragma GCC diagnostic ignored "-Wdeprecated-declarations" | |
181 | ||
aac2878e | 182 | /// One of the @link arithmetic_functors math functors@endlink. |
bd1a56a0 | 183 | template<typename _Tp> |
92ff3e43 | 184 | struct plus : public binary_function<_Tp, _Tp, _Tp> |
ed6814f7 | 185 | { |
828176ba | 186 | /// Returns the sum |
8dff34fe | 187 | _GLIBCXX14_CONSTEXPR |
f6592a9e PC |
188 | _Tp |
189 | operator()(const _Tp& __x, const _Tp& __y) const | |
190 | { return __x + __y; } | |
191 | }; | |
192 | ||
aac2878e | 193 | /// One of the @link arithmetic_functors math functors@endlink. |
bd1a56a0 | 194 | template<typename _Tp> |
92ff3e43 | 195 | struct minus : public binary_function<_Tp, _Tp, _Tp> |
f6592a9e | 196 | { |
8dff34fe | 197 | _GLIBCXX14_CONSTEXPR |
f6592a9e PC |
198 | _Tp |
199 | operator()(const _Tp& __x, const _Tp& __y) const | |
200 | { return __x - __y; } | |
201 | }; | |
202 | ||
aac2878e | 203 | /// One of the @link arithmetic_functors math functors@endlink. |
bd1a56a0 | 204 | template<typename _Tp> |
92ff3e43 | 205 | struct multiplies : public binary_function<_Tp, _Tp, _Tp> |
f6592a9e | 206 | { |
8dff34fe | 207 | _GLIBCXX14_CONSTEXPR |
f6592a9e PC |
208 | _Tp |
209 | operator()(const _Tp& __x, const _Tp& __y) const | |
210 | { return __x * __y; } | |
211 | }; | |
212 | ||
aac2878e | 213 | /// One of the @link arithmetic_functors math functors@endlink. |
bd1a56a0 | 214 | template<typename _Tp> |
92ff3e43 | 215 | struct divides : public binary_function<_Tp, _Tp, _Tp> |
f6592a9e | 216 | { |
8dff34fe | 217 | _GLIBCXX14_CONSTEXPR |
f6592a9e PC |
218 | _Tp |
219 | operator()(const _Tp& __x, const _Tp& __y) const | |
220 | { return __x / __y; } | |
221 | }; | |
222 | ||
aac2878e | 223 | /// One of the @link arithmetic_functors math functors@endlink. |
bd1a56a0 | 224 | template<typename _Tp> |
92ff3e43 | 225 | struct modulus : public binary_function<_Tp, _Tp, _Tp> |
f6592a9e | 226 | { |
8dff34fe | 227 | _GLIBCXX14_CONSTEXPR |
f6592a9e PC |
228 | _Tp |
229 | operator()(const _Tp& __x, const _Tp& __y) const | |
230 | { return __x % __y; } | |
231 | }; | |
232 | ||
aac2878e | 233 | /// One of the @link arithmetic_functors math functors@endlink. |
bd1a56a0 | 234 | template<typename _Tp> |
92ff3e43 | 235 | struct negate : public unary_function<_Tp, _Tp> |
f6592a9e | 236 | { |
8dff34fe | 237 | _GLIBCXX14_CONSTEXPR |
f6592a9e PC |
238 | _Tp |
239 | operator()(const _Tp& __x) const | |
240 | { return -__x; } | |
241 | }; | |
de196e5d | 242 | #pragma GCC diagnostic pop |
d081231a | 243 | |
7ffa63df | 244 | #ifdef __glibcxx_transparent_operators // C++ >= 14 |
d081231a JW |
245 | template<> |
246 | struct plus<void> | |
247 | { | |
248 | template <typename _Tp, typename _Up> | |
8dff34fe | 249 | _GLIBCXX14_CONSTEXPR |
d081231a JW |
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); } | |
255 | ||
256 | typedef __is_transparent is_transparent; | |
257 | }; | |
258 | ||
259 | /// One of the @link arithmetic_functors math functors@endlink. | |
260 | template<> | |
261 | struct minus<void> | |
262 | { | |
263 | template <typename _Tp, typename _Up> | |
8dff34fe | 264 | _GLIBCXX14_CONSTEXPR |
d081231a JW |
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); } | |
270 | ||
271 | typedef __is_transparent is_transparent; | |
272 | }; | |
273 | ||
274 | /// One of the @link arithmetic_functors math functors@endlink. | |
275 | template<> | |
276 | struct multiplies<void> | |
277 | { | |
278 | template <typename _Tp, typename _Up> | |
8dff34fe | 279 | _GLIBCXX14_CONSTEXPR |
d081231a JW |
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); } | |
285 | ||
286 | typedef __is_transparent is_transparent; | |
287 | }; | |
288 | ||
289 | /// One of the @link arithmetic_functors math functors@endlink. | |
290 | template<> | |
291 | struct divides<void> | |
292 | { | |
293 | template <typename _Tp, typename _Up> | |
8dff34fe | 294 | _GLIBCXX14_CONSTEXPR |
d081231a JW |
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); } | |
300 | ||
301 | typedef __is_transparent is_transparent; | |
302 | }; | |
303 | ||
304 | /// One of the @link arithmetic_functors math functors@endlink. | |
305 | template<> | |
306 | struct modulus<void> | |
307 | { | |
308 | template <typename _Tp, typename _Up> | |
8dff34fe | 309 | _GLIBCXX14_CONSTEXPR |
d081231a JW |
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); } | |
315 | ||
316 | typedef __is_transparent is_transparent; | |
317 | }; | |
318 | ||
319 | /// One of the @link arithmetic_functors math functors@endlink. | |
320 | template<> | |
321 | struct negate<void> | |
322 | { | |
323 | template <typename _Tp> | |
8dff34fe | 324 | _GLIBCXX14_CONSTEXPR |
d081231a JW |
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); } | |
330 | ||
331 | typedef __is_transparent is_transparent; | |
332 | }; | |
333 | #endif | |
f6592a9e PC |
334 | /** @} */ |
335 | ||
336 | // 20.3.3 comparisons | |
aac2878e | 337 | /** @defgroup comparison_functors Comparison Classes |
828176ba | 338 | * @ingroup functors |
aac2878e | 339 | * |
f6592a9e PC |
340 | * The library provides six wrapper functors for all the basic comparisons |
341 | * in C++, like @c <. | |
342 | * | |
343 | * @{ | |
344 | */ | |
7ffa63df | 345 | #if __glibcxx_transparent_operators // C++ >= 14 |
d081231a JW |
346 | template<typename _Tp = void> |
347 | struct equal_to; | |
348 | ||
349 | template<typename _Tp = void> | |
350 | struct not_equal_to; | |
351 | ||
352 | template<typename _Tp = void> | |
353 | struct greater; | |
354 | ||
355 | template<typename _Tp = void> | |
356 | struct less; | |
357 | ||
358 | template<typename _Tp = void> | |
359 | struct greater_equal; | |
360 | ||
361 | template<typename _Tp = void> | |
362 | struct less_equal; | |
363 | #endif | |
364 | ||
de196e5d JW |
365 | #pragma GCC diagnostic push |
366 | #pragma GCC diagnostic ignored "-Wdeprecated-declarations" | |
367 | ||
aac2878e | 368 | /// One of the @link comparison_functors comparison functors@endlink. |
bd1a56a0 | 369 | template<typename _Tp> |
ed6814f7 | 370 | struct equal_to : public binary_function<_Tp, _Tp, bool> |
f6592a9e | 371 | { |
8dff34fe | 372 | _GLIBCXX14_CONSTEXPR |
f6592a9e PC |
373 | bool |
374 | operator()(const _Tp& __x, const _Tp& __y) const | |
375 | { return __x == __y; } | |
376 | }; | |
377 | ||
aac2878e | 378 | /// One of the @link comparison_functors comparison functors@endlink. |
bd1a56a0 | 379 | template<typename _Tp> |
ed6814f7 | 380 | struct not_equal_to : public binary_function<_Tp, _Tp, bool> |
f6592a9e | 381 | { |
8dff34fe | 382 | _GLIBCXX14_CONSTEXPR |
f6592a9e PC |
383 | bool |
384 | operator()(const _Tp& __x, const _Tp& __y) const | |
385 | { return __x != __y; } | |
386 | }; | |
387 | ||
aac2878e | 388 | /// One of the @link comparison_functors comparison functors@endlink. |
bd1a56a0 | 389 | template<typename _Tp> |
92ff3e43 | 390 | struct greater : public binary_function<_Tp, _Tp, bool> |
f6592a9e | 391 | { |
8dff34fe | 392 | _GLIBCXX14_CONSTEXPR |
f6592a9e PC |
393 | bool |
394 | operator()(const _Tp& __x, const _Tp& __y) const | |
395 | { return __x > __y; } | |
396 | }; | |
397 | ||
aac2878e | 398 | /// One of the @link comparison_functors comparison functors@endlink. |
bd1a56a0 | 399 | template<typename _Tp> |
92ff3e43 | 400 | struct less : public binary_function<_Tp, _Tp, bool> |
f6592a9e | 401 | { |
8dff34fe | 402 | _GLIBCXX14_CONSTEXPR |
f6592a9e PC |
403 | bool |
404 | operator()(const _Tp& __x, const _Tp& __y) const | |
405 | { return __x < __y; } | |
406 | }; | |
407 | ||
aac2878e | 408 | /// One of the @link comparison_functors comparison functors@endlink. |
bd1a56a0 | 409 | template<typename _Tp> |
92ff3e43 | 410 | struct greater_equal : public binary_function<_Tp, _Tp, bool> |
f6592a9e | 411 | { |
8dff34fe | 412 | _GLIBCXX14_CONSTEXPR |
f6592a9e PC |
413 | bool |
414 | operator()(const _Tp& __x, const _Tp& __y) const | |
415 | { return __x >= __y; } | |
416 | }; | |
417 | ||
aac2878e | 418 | /// One of the @link comparison_functors comparison functors@endlink. |
bd1a56a0 | 419 | template<typename _Tp> |
92ff3e43 | 420 | struct less_equal : public binary_function<_Tp, _Tp, bool> |
f6592a9e | 421 | { |
8dff34fe | 422 | _GLIBCXX14_CONSTEXPR |
f6592a9e PC |
423 | bool |
424 | operator()(const _Tp& __x, const _Tp& __y) const | |
425 | { return __x <= __y; } | |
426 | }; | |
d081231a | 427 | |
0b3ec8f4 JW |
428 | // Partial specialization of std::greater for pointers. |
429 | template<typename _Tp> | |
430 | struct greater<_Tp*> : public binary_function<_Tp*, _Tp*, bool> | |
431 | { | |
432 | _GLIBCXX14_CONSTEXPR bool | |
433 | operator()(_Tp* __x, _Tp* __y) const _GLIBCXX_NOTHROW | |
434 | { | |
6cdf1946 | 435 | #if __cplusplus >= 201402L |
74d14778 | 436 | if (std::__is_constant_evaluated()) |
0b3ec8f4 | 437 | return __x > __y; |
6cdf1946 | 438 | #endif |
0b3ec8f4 JW |
439 | return (__UINTPTR_TYPE__)__x > (__UINTPTR_TYPE__)__y; |
440 | } | |
441 | }; | |
442 | ||
443 | // Partial specialization of std::less for pointers. | |
444 | template<typename _Tp> | |
445 | struct less<_Tp*> : public binary_function<_Tp*, _Tp*, bool> | |
446 | { | |
447 | _GLIBCXX14_CONSTEXPR bool | |
448 | operator()(_Tp* __x, _Tp* __y) const _GLIBCXX_NOTHROW | |
449 | { | |
6cdf1946 | 450 | #if __cplusplus >= 201402L |
74d14778 | 451 | if (std::__is_constant_evaluated()) |
0b3ec8f4 | 452 | return __x < __y; |
6cdf1946 | 453 | #endif |
0b3ec8f4 JW |
454 | return (__UINTPTR_TYPE__)__x < (__UINTPTR_TYPE__)__y; |
455 | } | |
456 | }; | |
457 | ||
458 | // Partial specialization of std::greater_equal for pointers. | |
459 | template<typename _Tp> | |
460 | struct greater_equal<_Tp*> : public binary_function<_Tp*, _Tp*, bool> | |
461 | { | |
462 | _GLIBCXX14_CONSTEXPR bool | |
463 | operator()(_Tp* __x, _Tp* __y) const _GLIBCXX_NOTHROW | |
464 | { | |
6cdf1946 | 465 | #if __cplusplus >= 201402L |
74d14778 | 466 | if (std::__is_constant_evaluated()) |
0b3ec8f4 | 467 | return __x >= __y; |
6cdf1946 | 468 | #endif |
0b3ec8f4 JW |
469 | return (__UINTPTR_TYPE__)__x >= (__UINTPTR_TYPE__)__y; |
470 | } | |
471 | }; | |
472 | ||
473 | // Partial specialization of std::less_equal for pointers. | |
474 | template<typename _Tp> | |
475 | struct less_equal<_Tp*> : public binary_function<_Tp*, _Tp*, bool> | |
476 | { | |
477 | _GLIBCXX14_CONSTEXPR bool | |
478 | operator()(_Tp* __x, _Tp* __y) const _GLIBCXX_NOTHROW | |
479 | { | |
6cdf1946 | 480 | #if __cplusplus >= 201402L |
74d14778 | 481 | if (std::__is_constant_evaluated()) |
0b3ec8f4 | 482 | return __x <= __y; |
6cdf1946 | 483 | #endif |
0b3ec8f4 JW |
484 | return (__UINTPTR_TYPE__)__x <= (__UINTPTR_TYPE__)__y; |
485 | } | |
486 | }; | |
de196e5d | 487 | #pragma GCC diagnostic pop |
0b3ec8f4 | 488 | |
7ffa63df | 489 | #ifdef __glibcxx_transparent_operators // C++ >= 14 |
d081231a JW |
490 | /// One of the @link comparison_functors comparison functors@endlink. |
491 | template<> | |
492 | struct equal_to<void> | |
493 | { | |
494 | template <typename _Tp, typename _Up> | |
0b3ec8f4 | 495 | constexpr auto |
d081231a JW |
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); } | |
500 | ||
501 | typedef __is_transparent is_transparent; | |
502 | }; | |
503 | ||
504 | /// One of the @link comparison_functors comparison functors@endlink. | |
505 | template<> | |
506 | struct not_equal_to<void> | |
507 | { | |
508 | template <typename _Tp, typename _Up> | |
0b3ec8f4 | 509 | constexpr auto |
d081231a JW |
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); } | |
514 | ||
515 | typedef __is_transparent is_transparent; | |
516 | }; | |
517 | ||
518 | /// One of the @link comparison_functors comparison functors@endlink. | |
519 | template<> | |
520 | struct greater<void> | |
521 | { | |
522 | template <typename _Tp, typename _Up> | |
0b3ec8f4 | 523 | constexpr auto |
d081231a JW |
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)) | |
0b3ec8f4 JW |
527 | { |
528 | return _S_cmp(std::forward<_Tp>(__t), std::forward<_Up>(__u), | |
529 | __ptr_cmp<_Tp, _Up>{}); | |
530 | } | |
531 | ||
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); } | |
d081231a JW |
536 | |
537 | typedef __is_transparent is_transparent; | |
0b3ec8f4 JW |
538 | |
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); } | |
544 | ||
545 | template <typename _Tp, typename _Up> | |
546 | static constexpr bool | |
547 | _S_cmp(_Tp&& __t, _Up&& __u, true_type) noexcept | |
548 | { | |
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))); | |
552 | } | |
553 | ||
7c69a7d9 | 554 | // True if there is no viable operator> member function. |
0b3ec8f4 JW |
555 | template<typename _Tp, typename _Up, typename = void> |
556 | struct __not_overloaded2 : true_type { }; | |
557 | ||
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 { }; | |
563 | ||
7c69a7d9 JW |
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> { }; | |
567 | ||
568 | // False if we can call operator>(T,U) | |
0b3ec8f4 | 569 | template<typename _Tp, typename _Up> |
7c69a7d9 JW |
570 | struct __not_overloaded<_Tp, _Up, __void_t< |
571 | decltype(operator>(std::declval<_Tp>(), std::declval<_Up>()))>> | |
572 | : false_type { }; | |
0b3ec8f4 JW |
573 | |
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*>>; | |
d081231a JW |
578 | }; |
579 | ||
580 | /// One of the @link comparison_functors comparison functors@endlink. | |
581 | template<> | |
582 | struct less<void> | |
583 | { | |
584 | template <typename _Tp, typename _Up> | |
0b3ec8f4 | 585 | constexpr auto |
d081231a JW |
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)) | |
0b3ec8f4 JW |
589 | { |
590 | return _S_cmp(std::forward<_Tp>(__t), std::forward<_Up>(__u), | |
591 | __ptr_cmp<_Tp, _Up>{}); | |
592 | } | |
593 | ||
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); } | |
d081231a JW |
598 | |
599 | typedef __is_transparent is_transparent; | |
0b3ec8f4 JW |
600 | |
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); } | |
606 | ||
607 | template <typename _Tp, typename _Up> | |
608 | static constexpr bool | |
609 | _S_cmp(_Tp&& __t, _Up&& __u, true_type) noexcept | |
610 | { | |
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))); | |
614 | } | |
615 | ||
7c69a7d9 | 616 | // True if there is no viable operator< member function. |
0b3ec8f4 JW |
617 | template<typename _Tp, typename _Up, typename = void> |
618 | struct __not_overloaded2 : true_type { }; | |
619 | ||
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 { }; | |
625 | ||
7c69a7d9 JW |
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> { }; | |
629 | ||
630 | // False if we can call operator<(T,U) | |
0b3ec8f4 | 631 | template<typename _Tp, typename _Up> |
7c69a7d9 JW |
632 | struct __not_overloaded<_Tp, _Up, __void_t< |
633 | decltype(operator<(std::declval<_Tp>(), std::declval<_Up>()))>> | |
634 | : false_type { }; | |
0b3ec8f4 JW |
635 | |
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*>>; | |
d081231a JW |
640 | }; |
641 | ||
642 | /// One of the @link comparison_functors comparison functors@endlink. | |
643 | template<> | |
644 | struct greater_equal<void> | |
645 | { | |
646 | template <typename _Tp, typename _Up> | |
0b3ec8f4 | 647 | constexpr auto |
d081231a JW |
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)) | |
0b3ec8f4 JW |
651 | { |
652 | return _S_cmp(std::forward<_Tp>(__t), std::forward<_Up>(__u), | |
653 | __ptr_cmp<_Tp, _Up>{}); | |
654 | } | |
655 | ||
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); } | |
d081231a JW |
660 | |
661 | typedef __is_transparent is_transparent; | |
0b3ec8f4 JW |
662 | |
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); } | |
668 | ||
669 | template <typename _Tp, typename _Up> | |
670 | static constexpr bool | |
671 | _S_cmp(_Tp&& __t, _Up&& __u, true_type) noexcept | |
672 | { | |
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))); | |
676 | } | |
677 | ||
7c69a7d9 | 678 | // True if there is no viable operator>= member function. |
0b3ec8f4 JW |
679 | template<typename _Tp, typename _Up, typename = void> |
680 | struct __not_overloaded2 : true_type { }; | |
681 | ||
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 { }; | |
687 | ||
7c69a7d9 JW |
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> { }; | |
691 | ||
692 | // False if we can call operator>=(T,U) | |
0b3ec8f4 | 693 | template<typename _Tp, typename _Up> |
7c69a7d9 JW |
694 | struct __not_overloaded<_Tp, _Up, __void_t< |
695 | decltype(operator>=(std::declval<_Tp>(), std::declval<_Up>()))>> | |
696 | : false_type { }; | |
0b3ec8f4 JW |
697 | |
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*>>; | |
d081231a JW |
702 | }; |
703 | ||
704 | /// One of the @link comparison_functors comparison functors@endlink. | |
705 | template<> | |
706 | struct less_equal<void> | |
707 | { | |
708 | template <typename _Tp, typename _Up> | |
0b3ec8f4 | 709 | constexpr auto |
d081231a JW |
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)) | |
0b3ec8f4 JW |
713 | { |
714 | return _S_cmp(std::forward<_Tp>(__t), std::forward<_Up>(__u), | |
715 | __ptr_cmp<_Tp, _Up>{}); | |
716 | } | |
717 | ||
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); } | |
d081231a JW |
722 | |
723 | typedef __is_transparent is_transparent; | |
0b3ec8f4 JW |
724 | |
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); } | |
730 | ||
731 | template <typename _Tp, typename _Up> | |
732 | static constexpr bool | |
733 | _S_cmp(_Tp&& __t, _Up&& __u, true_type) noexcept | |
734 | { | |
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))); | |
738 | } | |
739 | ||
7c69a7d9 | 740 | // True if there is no viable operator<= member function. |
0b3ec8f4 JW |
741 | template<typename _Tp, typename _Up, typename = void> |
742 | struct __not_overloaded2 : true_type { }; | |
743 | ||
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 { }; | |
749 | ||
7c69a7d9 JW |
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> { }; | |
753 | ||
754 | // False if we can call operator<=(T,U) | |
0b3ec8f4 | 755 | template<typename _Tp, typename _Up> |
7c69a7d9 JW |
756 | struct __not_overloaded<_Tp, _Up, __void_t< |
757 | decltype(operator<=(std::declval<_Tp>(), std::declval<_Up>()))>> | |
758 | : false_type { }; | |
0b3ec8f4 JW |
759 | |
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*>>; | |
d081231a | 764 | }; |
7ffa63df | 765 | #endif // __glibcxx_transparent_operators |
f6592a9e | 766 | /** @} */ |
ed6814f7 | 767 | |
f6592a9e | 768 | // 20.3.4 logical operations |
aac2878e | 769 | /** @defgroup logical_functors Boolean Operations Classes |
828176ba | 770 | * @ingroup functors |
aac2878e | 771 | * |
828176ba JW |
772 | * The library provides function objects for the logical operations: |
773 | * `&&`, `||`, and `!`. | |
f6592a9e PC |
774 | * |
775 | * @{ | |
776 | */ | |
7ffa63df | 777 | #ifdef __glibcxx_transparent_operators // C++ >= 14 |
d081231a JW |
778 | template<typename _Tp = void> |
779 | struct logical_and; | |
780 | ||
781 | template<typename _Tp = void> | |
782 | struct logical_or; | |
783 | ||
784 | template<typename _Tp = void> | |
785 | struct logical_not; | |
786 | #endif | |
787 | ||
de196e5d JW |
788 | #pragma GCC diagnostic push |
789 | #pragma GCC diagnostic ignored "-Wdeprecated-declarations" | |
790 | ||
aac2878e | 791 | /// One of the @link logical_functors Boolean operations functors@endlink. |
bd1a56a0 | 792 | template<typename _Tp> |
92ff3e43 | 793 | struct logical_and : public binary_function<_Tp, _Tp, bool> |
f6592a9e | 794 | { |
8dff34fe | 795 | _GLIBCXX14_CONSTEXPR |
f6592a9e PC |
796 | bool |
797 | operator()(const _Tp& __x, const _Tp& __y) const | |
798 | { return __x && __y; } | |
799 | }; | |
800 | ||
aac2878e | 801 | /// One of the @link logical_functors Boolean operations functors@endlink. |
bd1a56a0 | 802 | template<typename _Tp> |
92ff3e43 | 803 | struct logical_or : public binary_function<_Tp, _Tp, bool> |
f6592a9e | 804 | { |
8dff34fe | 805 | _GLIBCXX14_CONSTEXPR |
f6592a9e PC |
806 | bool |
807 | operator()(const _Tp& __x, const _Tp& __y) const | |
808 | { return __x || __y; } | |
809 | }; | |
810 | ||
aac2878e | 811 | /// One of the @link logical_functors Boolean operations functors@endlink. |
bd1a56a0 | 812 | template<typename _Tp> |
92ff3e43 | 813 | struct logical_not : public unary_function<_Tp, bool> |
f6592a9e | 814 | { |
8dff34fe | 815 | _GLIBCXX14_CONSTEXPR |
f6592a9e PC |
816 | bool |
817 | operator()(const _Tp& __x) const | |
818 | { return !__x; } | |
819 | }; | |
de196e5d | 820 | #pragma GCC diagnostic pop |
d081231a | 821 | |
7ffa63df | 822 | #ifdef __glibcxx_transparent_operators // C++ >= 14 |
d081231a JW |
823 | /// One of the @link logical_functors Boolean operations functors@endlink. |
824 | template<> | |
825 | struct logical_and<void> | |
826 | { | |
827 | template <typename _Tp, typename _Up> | |
8dff34fe | 828 | _GLIBCXX14_CONSTEXPR |
d081231a JW |
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); } | |
834 | ||
835 | typedef __is_transparent is_transparent; | |
836 | }; | |
837 | ||
838 | /// One of the @link logical_functors Boolean operations functors@endlink. | |
839 | template<> | |
840 | struct logical_or<void> | |
841 | { | |
842 | template <typename _Tp, typename _Up> | |
8dff34fe | 843 | _GLIBCXX14_CONSTEXPR |
d081231a JW |
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); } | |
849 | ||
850 | typedef __is_transparent is_transparent; | |
851 | }; | |
852 | ||
853 | /// One of the @link logical_functors Boolean operations functors@endlink. | |
854 | template<> | |
855 | struct logical_not<void> | |
856 | { | |
857 | template <typename _Tp> | |
8dff34fe | 858 | _GLIBCXX14_CONSTEXPR |
d081231a | 859 | auto |
bef49287 JW |
860 | operator()(_Tp&& __t) const |
861 | noexcept(noexcept(!std::forward<_Tp>(__t))) | |
862 | -> decltype(!std::forward<_Tp>(__t)) | |
d081231a JW |
863 | { return !std::forward<_Tp>(__t); } |
864 | ||
865 | typedef __is_transparent is_transparent; | |
866 | }; | |
7ffa63df | 867 | #endif // __glibcxx_transparent_operators |
f6592a9e PC |
868 | /** @} */ |
869 | ||
7ffa63df | 870 | #ifdef __glibcxx_transparent_operators // C++ >= 14 |
d081231a JW |
871 | template<typename _Tp = void> |
872 | struct bit_and; | |
873 | ||
874 | template<typename _Tp = void> | |
875 | struct bit_or; | |
876 | ||
877 | template<typename _Tp = void> | |
878 | struct bit_xor; | |
879 | ||
880 | template<typename _Tp = void> | |
881 | struct bit_not; | |
882 | #endif | |
883 | ||
de196e5d JW |
884 | #pragma GCC diagnostic push |
885 | #pragma GCC diagnostic ignored "-Wdeprecated-declarations" | |
886 | ||
2ee0c1fb PC |
887 | // _GLIBCXX_RESOLVE_LIB_DEFECTS |
888 | // DR 660. Missing Bitwise Operations. | |
bd1a56a0 | 889 | template<typename _Tp> |
2ee0c1fb PC |
890 | struct bit_and : public binary_function<_Tp, _Tp, _Tp> |
891 | { | |
8dff34fe | 892 | _GLIBCXX14_CONSTEXPR |
2ee0c1fb PC |
893 | _Tp |
894 | operator()(const _Tp& __x, const _Tp& __y) const | |
895 | { return __x & __y; } | |
896 | }; | |
897 | ||
bd1a56a0 | 898 | template<typename _Tp> |
2ee0c1fb PC |
899 | struct bit_or : public binary_function<_Tp, _Tp, _Tp> |
900 | { | |
8dff34fe | 901 | _GLIBCXX14_CONSTEXPR |
2ee0c1fb PC |
902 | _Tp |
903 | operator()(const _Tp& __x, const _Tp& __y) const | |
904 | { return __x | __y; } | |
905 | }; | |
906 | ||
bd1a56a0 | 907 | template<typename _Tp> |
2ee0c1fb PC |
908 | struct bit_xor : public binary_function<_Tp, _Tp, _Tp> |
909 | { | |
8dff34fe | 910 | _GLIBCXX14_CONSTEXPR |
2ee0c1fb PC |
911 | _Tp |
912 | operator()(const _Tp& __x, const _Tp& __y) const | |
913 | { return __x ^ __y; } | |
914 | }; | |
915 | ||
d081231a JW |
916 | template<typename _Tp> |
917 | struct bit_not : public unary_function<_Tp, _Tp> | |
918 | { | |
8dff34fe | 919 | _GLIBCXX14_CONSTEXPR |
d081231a JW |
920 | _Tp |
921 | operator()(const _Tp& __x) const | |
922 | { return ~__x; } | |
923 | }; | |
de196e5d | 924 | #pragma GCC diagnostic pop |
d081231a | 925 | |
7ffa63df | 926 | #ifdef __glibcxx_transparent_operators // C++ >= 14 |
d081231a JW |
927 | template <> |
928 | struct bit_and<void> | |
929 | { | |
930 | template <typename _Tp, typename _Up> | |
8dff34fe | 931 | _GLIBCXX14_CONSTEXPR |
d081231a JW |
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_or<void> | |
943 | { | |
944 | template <typename _Tp, typename _Up> | |
8dff34fe | 945 | _GLIBCXX14_CONSTEXPR |
d081231a JW |
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_xor<void> | |
957 | { | |
958 | template <typename _Tp, typename _Up> | |
8dff34fe | 959 | _GLIBCXX14_CONSTEXPR |
d081231a JW |
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); } | |
965 | ||
966 | typedef __is_transparent is_transparent; | |
967 | }; | |
968 | ||
969 | template <> | |
970 | struct bit_not<void> | |
971 | { | |
972 | template <typename _Tp> | |
8dff34fe | 973 | _GLIBCXX14_CONSTEXPR |
d081231a JW |
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); } | |
979 | ||
980 | typedef __is_transparent is_transparent; | |
981 | }; | |
de196e5d JW |
982 | #endif // C++14 |
983 | ||
984 | #pragma GCC diagnostic push | |
985 | #pragma GCC diagnostic ignored "-Wdeprecated-declarations" | |
d081231a | 986 | |
f6592a9e | 987 | // 20.3.5 negators |
aac2878e | 988 | /** @defgroup negators Negators |
828176ba | 989 | * @ingroup functors |
aac2878e | 990 | * |
828176ba JW |
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. | |
f6592a9e PC |
996 | * |
997 | * For example, given a vector of integers and a trivial predicate, | |
998 | * \code | |
999 | * struct IntGreaterThanThree | |
1000 | * : public std::unary_function<int, bool> | |
1001 | * { | |
828176ba | 1002 | * bool operator() (int x) const { return x > 3; } |
f6592a9e | 1003 | * }; |
ed6814f7 | 1004 | * |
f6592a9e PC |
1005 | * std::find_if (v.begin(), v.end(), not1(IntGreaterThanThree())); |
1006 | * \endcode | |
828176ba JW |
1007 | * The call to `find_if` will locate the first index (i) of `v` for which |
1008 | * `!(v[i] > 3)` is true. | |
f6592a9e PC |
1009 | * |
1010 | * The not1/unary_negate combination works on predicates taking a single | |
828176ba JW |
1011 | * argument. The not2/binary_negate combination works on predicates taking |
1012 | * two arguments. | |
1013 | * | |
1014 | * @deprecated Deprecated in C++17, no longer in the standard since C++20. | |
1015 | * Use `not_fn` instead. | |
f6592a9e PC |
1016 | * |
1017 | * @{ | |
1018 | */ | |
aac2878e | 1019 | /// One of the @link negators negation functors@endlink. |
bd1a56a0 | 1020 | template<typename _Predicate> |
de196e5d | 1021 | class _GLIBCXX17_DEPRECATED unary_negate |
f6592a9e PC |
1022 | : public unary_function<typename _Predicate::argument_type, bool> |
1023 | { | |
1024 | protected: | |
1025 | _Predicate _M_pred; | |
bd1a56a0 | 1026 | |
f6592a9e | 1027 | public: |
8dff34fe | 1028 | _GLIBCXX14_CONSTEXPR |
7c920151 | 1029 | explicit |
bd1a56a0 | 1030 | unary_negate(const _Predicate& __x) : _M_pred(__x) { } |
ed6814f7 | 1031 | |
8dff34fe | 1032 | _GLIBCXX14_CONSTEXPR |
f6592a9e PC |
1033 | bool |
1034 | operator()(const typename _Predicate::argument_type& __x) const | |
1035 | { return !_M_pred(__x); } | |
1036 | }; | |
1037 | ||
aac2878e | 1038 | /// One of the @link negators negation functors@endlink. |
bd1a56a0 | 1039 | template<typename _Predicate> |
de196e5d | 1040 | _GLIBCXX17_DEPRECATED_SUGGEST("std::not_fn") |
8dff34fe | 1041 | _GLIBCXX14_CONSTEXPR |
ed6814f7 | 1042 | inline unary_negate<_Predicate> |
f6592a9e PC |
1043 | not1(const _Predicate& __pred) |
1044 | { return unary_negate<_Predicate>(__pred); } | |
1045 | ||
aac2878e | 1046 | /// One of the @link negators negation functors@endlink. |
bd1a56a0 | 1047 | template<typename _Predicate> |
de196e5d | 1048 | class _GLIBCXX17_DEPRECATED binary_negate |
f6592a9e | 1049 | : public binary_function<typename _Predicate::first_argument_type, |
65be6ddd | 1050 | typename _Predicate::second_argument_type, bool> |
f6592a9e PC |
1051 | { |
1052 | protected: | |
1053 | _Predicate _M_pred; | |
65be6ddd | 1054 | |
f6592a9e | 1055 | public: |
8dff34fe | 1056 | _GLIBCXX14_CONSTEXPR |
7c920151 | 1057 | explicit |
65be6ddd | 1058 | binary_negate(const _Predicate& __x) : _M_pred(__x) { } |
f6592a9e | 1059 | |
8dff34fe | 1060 | _GLIBCXX14_CONSTEXPR |
f6592a9e | 1061 | bool |
ed6814f7 | 1062 | operator()(const typename _Predicate::first_argument_type& __x, |
f6592a9e PC |
1063 | const typename _Predicate::second_argument_type& __y) const |
1064 | { return !_M_pred(__x, __y); } | |
1065 | }; | |
1066 | ||
aac2878e | 1067 | /// One of the @link negators negation functors@endlink. |
bd1a56a0 | 1068 | template<typename _Predicate> |
de196e5d | 1069 | _GLIBCXX17_DEPRECATED_SUGGEST("std::not_fn") |
8dff34fe | 1070 | _GLIBCXX14_CONSTEXPR |
ed6814f7 | 1071 | inline binary_negate<_Predicate> |
f6592a9e PC |
1072 | not2(const _Predicate& __pred) |
1073 | { return binary_negate<_Predicate>(__pred); } | |
1074 | /** @} */ | |
ed6814f7 | 1075 | |
f6592a9e | 1076 | // 20.3.7 adaptors pointers functions |
aac2878e | 1077 | /** @defgroup pointer_adaptors Adaptors for pointers to functions |
828176ba | 1078 | * @ingroup functors |
aac2878e | 1079 | * |
f6592a9e PC |
1080 | * The advantage of function objects over pointers to functions is that |
1081 | * the objects in the standard library declare nested typedefs describing | |
828176ba JW |
1082 | * their argument and result types with uniform names (e.g., `result_type` |
1083 | * from the base classes `unary_function` and `binary_function`). | |
f6592a9e PC |
1084 | * Sometimes those typedefs are required, not just optional. |
1085 | * | |
1086 | * Adaptors are provided to turn pointers to unary (single-argument) and | |
1087 | * binary (double-argument) functions into function objects. The | |
828176ba JW |
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()`. | |
f6592a9e | 1092 | * |
828176ba | 1093 | * The function `ptr_fun` takes a pointer-to-function `f` and constructs |
f6592a9e PC |
1094 | * an instance of the appropriate functor. |
1095 | * | |
828176ba JW |
1096 | * @deprecated Deprecated in C++11, no longer in the standard since C++17. |
1097 | * | |
f6592a9e PC |
1098 | * @{ |
1099 | */ | |
aac2878e | 1100 | /// One of the @link pointer_adaptors adaptors for function pointers@endlink. |
bd1a56a0 | 1101 | template<typename _Arg, typename _Result> |
f6592a9e PC |
1102 | class pointer_to_unary_function : public unary_function<_Arg, _Result> |
1103 | { | |
1104 | protected: | |
1105 | _Result (*_M_ptr)(_Arg); | |
bd1a56a0 | 1106 | |
f6592a9e | 1107 | public: |
bd1a56a0 | 1108 | pointer_to_unary_function() { } |
ed6814f7 | 1109 | |
7c920151 PC |
1110 | explicit |
1111 | pointer_to_unary_function(_Result (*__x)(_Arg)) | |
bd1a56a0 | 1112 | : _M_ptr(__x) { } |
725dc051 | 1113 | |
f6592a9e PC |
1114 | _Result |
1115 | operator()(_Arg __x) const | |
1116 | { return _M_ptr(__x); } | |
de196e5d | 1117 | } _GLIBCXX11_DEPRECATED; |
f6592a9e | 1118 | |
aac2878e | 1119 | /// One of the @link pointer_adaptors adaptors for function pointers@endlink. |
bd1a56a0 | 1120 | template<typename _Arg, typename _Result> |
50bc6e46 | 1121 | _GLIBCXX11_DEPRECATED_SUGGEST("std::function") |
f6592a9e PC |
1122 | inline pointer_to_unary_function<_Arg, _Result> |
1123 | ptr_fun(_Result (*__x)(_Arg)) | |
1124 | { return pointer_to_unary_function<_Arg, _Result>(__x); } | |
1125 | ||
aac2878e | 1126 | /// One of the @link pointer_adaptors adaptors for function pointers@endlink. |
bd1a56a0 | 1127 | template<typename _Arg1, typename _Arg2, typename _Result> |
f6592a9e | 1128 | class pointer_to_binary_function |
afd4cbbb | 1129 | : public binary_function<_Arg1, _Arg2, _Result> |
f6592a9e PC |
1130 | { |
1131 | protected: | |
1132 | _Result (*_M_ptr)(_Arg1, _Arg2); | |
bd1a56a0 | 1133 | |
f6592a9e | 1134 | public: |
bd1a56a0 | 1135 | pointer_to_binary_function() { } |
f6592a9e | 1136 | |
7c920151 | 1137 | explicit |
ed6814f7 | 1138 | pointer_to_binary_function(_Result (*__x)(_Arg1, _Arg2)) |
bd1a56a0 | 1139 | : _M_ptr(__x) { } |
725dc051 | 1140 | |
f6592a9e PC |
1141 | _Result |
1142 | operator()(_Arg1 __x, _Arg2 __y) const | |
1143 | { return _M_ptr(__x, __y); } | |
de196e5d | 1144 | } _GLIBCXX11_DEPRECATED; |
f6592a9e | 1145 | |
aac2878e | 1146 | /// One of the @link pointer_adaptors adaptors for function pointers@endlink. |
bd1a56a0 | 1147 | template<typename _Arg1, typename _Arg2, typename _Result> |
50bc6e46 | 1148 | _GLIBCXX11_DEPRECATED_SUGGEST("std::function") |
ed6814f7 | 1149 | inline pointer_to_binary_function<_Arg1, _Arg2, _Result> |
f6592a9e PC |
1150 | ptr_fun(_Result (*__x)(_Arg1, _Arg2)) |
1151 | { return pointer_to_binary_function<_Arg1, _Arg2, _Result>(__x); } | |
1152 | /** @} */ | |
ed6814f7 | 1153 | |
bd1a56a0 | 1154 | template<typename _Tp> |
b9b09214 | 1155 | struct _Identity |
866e4d38 | 1156 | : public unary_function<_Tp, _Tp> |
f6592a9e PC |
1157 | { |
1158 | _Tp& | |
1159 | operator()(_Tp& __x) const | |
1160 | { return __x; } | |
ed6814f7 | 1161 | |
f6592a9e PC |
1162 | const _Tp& |
1163 | operator()(const _Tp& __x) const | |
1164 | { return __x; } | |
1165 | }; | |
1166 | ||
866e4d38 JW |
1167 | // Partial specialization, avoids confusing errors in e.g. std::set<const T>. |
1168 | template<typename _Tp> struct _Identity<const _Tp> : _Identity<_Tp> { }; | |
1169 | ||
bd1a56a0 | 1170 | template<typename _Pair> |
b9b09214 | 1171 | struct _Select1st |
b9b09214 | 1172 | : public unary_function<_Pair, typename _Pair::first_type> |
f6592a9e PC |
1173 | { |
1174 | typename _Pair::first_type& | |
1175 | operator()(_Pair& __x) const | |
1176 | { return __x.first; } | |
ed6814f7 | 1177 | |
f6592a9e PC |
1178 | const typename _Pair::first_type& |
1179 | operator()(const _Pair& __x) const | |
1180 | { return __x.first; } | |
777a1e28 | 1181 | |
734f5023 | 1182 | #if __cplusplus >= 201103L |
777a1e28 PC |
1183 | template<typename _Pair2> |
1184 | typename _Pair2::first_type& | |
1185 | operator()(_Pair2& __x) const | |
1186 | { return __x.first; } | |
1187 | ||
1188 | template<typename _Pair2> | |
1189 | const typename _Pair2::first_type& | |
1190 | operator()(const _Pair2& __x) const | |
1191 | { return __x.first; } | |
1192 | #endif | |
f6592a9e PC |
1193 | }; |
1194 | ||
bd1a56a0 | 1195 | template<typename _Pair> |
b9b09214 | 1196 | struct _Select2nd |
b9b09214 | 1197 | : public unary_function<_Pair, typename _Pair::second_type> |
f6592a9e PC |
1198 | { |
1199 | typename _Pair::second_type& | |
1200 | operator()(_Pair& __x) const | |
1201 | { return __x.second; } | |
ed6814f7 | 1202 | |
f6592a9e PC |
1203 | const typename _Pair::second_type& |
1204 | operator()(const _Pair& __x) const | |
1205 | { return __x.second; } | |
1206 | }; | |
1207 | ||
1208 | // 20.3.8 adaptors pointers members | |
828176ba JW |
1209 | /** @defgroup ptrmem_adaptors Adaptors for pointers to members |
1210 | * @ingroup functors | |
aac2878e | 1211 | * |
d5f261c1 | 1212 | * There are a total of 8 = 2^3 function objects in this family. |
f6592a9e PC |
1213 | * (1) Member functions taking no arguments vs member functions taking |
1214 | * one argument. | |
1215 | * (2) Call through pointer vs call through reference. | |
d5f261c1 | 1216 | * (3) Const vs non-const member function. |
f6592a9e PC |
1217 | * |
1218 | * All of this complexity is in the function objects themselves. You can | |
828176ba | 1219 | * ignore it by using the helper function `mem_fun` and `mem_fun_ref`, |
f6592a9e PC |
1220 | * which create whichever type of adaptor is appropriate. |
1221 | * | |
828176ba JW |
1222 | * @deprecated Deprecated in C++11, no longer in the standard since C++17. |
1223 | * Use `mem_fn` instead. | |
1224 | * | |
f6592a9e PC |
1225 | * @{ |
1226 | */ | |
828176ba | 1227 | /// One of the @link ptrmem_adaptors adaptors for member pointers@endlink. |
bd1a56a0 | 1228 | template<typename _Ret, typename _Tp> |
f6592a9e PC |
1229 | class mem_fun_t : public unary_function<_Tp*, _Ret> |
1230 | { | |
1231 | public: | |
7c920151 PC |
1232 | explicit |
1233 | mem_fun_t(_Ret (_Tp::*__pf)()) | |
bd1a56a0 | 1234 | : _M_f(__pf) { } |
f6592a9e PC |
1235 | |
1236 | _Ret | |
1237 | operator()(_Tp* __p) const | |
1238 | { return (__p->*_M_f)(); } | |
bd1a56a0 | 1239 | |
f6592a9e PC |
1240 | private: |
1241 | _Ret (_Tp::*_M_f)(); | |
de196e5d | 1242 | } _GLIBCXX11_DEPRECATED; |
f6592a9e | 1243 | |
828176ba | 1244 | /// One of the @link ptrmem_adaptors adaptors for member pointers@endlink. |
bd1a56a0 | 1245 | template<typename _Ret, typename _Tp> |
f6592a9e PC |
1246 | class const_mem_fun_t : public unary_function<const _Tp*, _Ret> |
1247 | { | |
1248 | public: | |
7c920151 PC |
1249 | explicit |
1250 | const_mem_fun_t(_Ret (_Tp::*__pf)() const) | |
bd1a56a0 | 1251 | : _M_f(__pf) { } |
f6592a9e PC |
1252 | |
1253 | _Ret | |
1254 | operator()(const _Tp* __p) const | |
1255 | { return (__p->*_M_f)(); } | |
bd1a56a0 | 1256 | |
f6592a9e PC |
1257 | private: |
1258 | _Ret (_Tp::*_M_f)() const; | |
de196e5d | 1259 | } _GLIBCXX11_DEPRECATED; |
f6592a9e | 1260 | |
828176ba | 1261 | /// One of the @link ptrmem_adaptors adaptors for member pointers@endlink. |
bd1a56a0 | 1262 | template<typename _Ret, typename _Tp> |
f6592a9e PC |
1263 | class mem_fun_ref_t : public unary_function<_Tp, _Ret> |
1264 | { | |
1265 | public: | |
7c920151 PC |
1266 | explicit |
1267 | mem_fun_ref_t(_Ret (_Tp::*__pf)()) | |
bd1a56a0 | 1268 | : _M_f(__pf) { } |
f6592a9e PC |
1269 | |
1270 | _Ret | |
1271 | operator()(_Tp& __r) const | |
1272 | { return (__r.*_M_f)(); } | |
bd1a56a0 | 1273 | |
f6592a9e PC |
1274 | private: |
1275 | _Ret (_Tp::*_M_f)(); | |
de196e5d | 1276 | } _GLIBCXX11_DEPRECATED; |
ed6814f7 | 1277 | |
828176ba | 1278 | /// One of the @link ptrmem_adaptors adaptors for member pointers@endlink. |
bd1a56a0 | 1279 | template<typename _Ret, typename _Tp> |
f6592a9e PC |
1280 | class const_mem_fun_ref_t : public unary_function<_Tp, _Ret> |
1281 | { | |
1282 | public: | |
7c920151 PC |
1283 | explicit |
1284 | const_mem_fun_ref_t(_Ret (_Tp::*__pf)() const) | |
bd1a56a0 | 1285 | : _M_f(__pf) { } |
f6592a9e PC |
1286 | |
1287 | _Ret | |
1288 | operator()(const _Tp& __r) const | |
1289 | { return (__r.*_M_f)(); } | |
bd1a56a0 | 1290 | |
f6592a9e PC |
1291 | private: |
1292 | _Ret (_Tp::*_M_f)() const; | |
de196e5d | 1293 | } _GLIBCXX11_DEPRECATED; |
f6592a9e | 1294 | |
828176ba | 1295 | /// One of the @link ptrmem_adaptors adaptors for member pointers@endlink. |
bd1a56a0 | 1296 | template<typename _Ret, typename _Tp, typename _Arg> |
f6592a9e PC |
1297 | class mem_fun1_t : public binary_function<_Tp*, _Arg, _Ret> |
1298 | { | |
1299 | public: | |
7c920151 | 1300 | explicit |
ed6814f7 | 1301 | mem_fun1_t(_Ret (_Tp::*__pf)(_Arg)) |
bd1a56a0 | 1302 | : _M_f(__pf) { } |
f6592a9e PC |
1303 | |
1304 | _Ret | |
1305 | operator()(_Tp* __p, _Arg __x) const | |
1306 | { return (__p->*_M_f)(__x); } | |
bd1a56a0 | 1307 | |
f6592a9e PC |
1308 | private: |
1309 | _Ret (_Tp::*_M_f)(_Arg); | |
de196e5d | 1310 | } _GLIBCXX11_DEPRECATED; |
f6592a9e | 1311 | |
828176ba | 1312 | /// One of the @link ptrmem_adaptors adaptors for member pointers@endlink. |
bd1a56a0 | 1313 | template<typename _Ret, typename _Tp, typename _Arg> |
f6592a9e PC |
1314 | class const_mem_fun1_t : public binary_function<const _Tp*, _Arg, _Ret> |
1315 | { | |
1316 | public: | |
7c920151 PC |
1317 | explicit |
1318 | const_mem_fun1_t(_Ret (_Tp::*__pf)(_Arg) const) | |
bd1a56a0 | 1319 | : _M_f(__pf) { } |
f6592a9e PC |
1320 | |
1321 | _Ret | |
1322 | operator()(const _Tp* __p, _Arg __x) const | |
1323 | { return (__p->*_M_f)(__x); } | |
bd1a56a0 | 1324 | |
f6592a9e PC |
1325 | private: |
1326 | _Ret (_Tp::*_M_f)(_Arg) const; | |
de196e5d | 1327 | } _GLIBCXX11_DEPRECATED; |
f6592a9e | 1328 | |
828176ba | 1329 | /// One of the @link ptrmem_adaptors adaptors for member pointers@endlink. |
bd1a56a0 | 1330 | template<typename _Ret, typename _Tp, typename _Arg> |
f6592a9e PC |
1331 | class mem_fun1_ref_t : public binary_function<_Tp, _Arg, _Ret> |
1332 | { | |
1333 | public: | |
7c920151 PC |
1334 | explicit |
1335 | mem_fun1_ref_t(_Ret (_Tp::*__pf)(_Arg)) | |
bd1a56a0 | 1336 | : _M_f(__pf) { } |
f6592a9e PC |
1337 | |
1338 | _Ret | |
1339 | operator()(_Tp& __r, _Arg __x) const | |
1340 | { return (__r.*_M_f)(__x); } | |
bd1a56a0 | 1341 | |
f6592a9e PC |
1342 | private: |
1343 | _Ret (_Tp::*_M_f)(_Arg); | |
de196e5d | 1344 | } _GLIBCXX11_DEPRECATED; |
f6592a9e | 1345 | |
828176ba | 1346 | /// One of the @link ptrmem_adaptors adaptors for member pointers@endlink. |
bd1a56a0 | 1347 | template<typename _Ret, typename _Tp, typename _Arg> |
f6592a9e PC |
1348 | class const_mem_fun1_ref_t : public binary_function<_Tp, _Arg, _Ret> |
1349 | { | |
1350 | public: | |
7c920151 PC |
1351 | explicit |
1352 | const_mem_fun1_ref_t(_Ret (_Tp::*__pf)(_Arg) const) | |
bd1a56a0 | 1353 | : _M_f(__pf) { } |
f6592a9e PC |
1354 | |
1355 | _Ret | |
1356 | operator()(const _Tp& __r, _Arg __x) const | |
1357 | { return (__r.*_M_f)(__x); } | |
bd1a56a0 | 1358 | |
f6592a9e PC |
1359 | private: |
1360 | _Ret (_Tp::*_M_f)(_Arg) const; | |
de196e5d | 1361 | } _GLIBCXX11_DEPRECATED; |
ed6814f7 | 1362 | |
f6592a9e PC |
1363 | // Mem_fun adaptor helper functions. There are only two: |
1364 | // mem_fun and mem_fun_ref. | |
bd1a56a0 | 1365 | template<typename _Ret, typename _Tp> |
de196e5d | 1366 | _GLIBCXX11_DEPRECATED_SUGGEST("std::mem_fn") |
92ff3e43 | 1367 | inline mem_fun_t<_Ret, _Tp> |
f6592a9e | 1368 | mem_fun(_Ret (_Tp::*__f)()) |
92ff3e43 | 1369 | { return mem_fun_t<_Ret, _Tp>(__f); } |
f6592a9e | 1370 | |
bd1a56a0 | 1371 | template<typename _Ret, typename _Tp> |
de196e5d | 1372 | _GLIBCXX11_DEPRECATED_SUGGEST("std::mem_fn") |
92ff3e43 | 1373 | inline const_mem_fun_t<_Ret, _Tp> |
f6592a9e | 1374 | mem_fun(_Ret (_Tp::*__f)() const) |
92ff3e43 | 1375 | { return const_mem_fun_t<_Ret, _Tp>(__f); } |
ed6814f7 | 1376 | |
bd1a56a0 | 1377 | template<typename _Ret, typename _Tp> |
de196e5d | 1378 | _GLIBCXX11_DEPRECATED_SUGGEST("std::mem_fn") |
92ff3e43 | 1379 | inline mem_fun_ref_t<_Ret, _Tp> |
ed6814f7 | 1380 | mem_fun_ref(_Ret (_Tp::*__f)()) |
92ff3e43 | 1381 | { return mem_fun_ref_t<_Ret, _Tp>(__f); } |
f6592a9e | 1382 | |
bd1a56a0 | 1383 | template<typename _Ret, typename _Tp> |
de196e5d | 1384 | _GLIBCXX11_DEPRECATED_SUGGEST("std::mem_fn") |
92ff3e43 | 1385 | inline const_mem_fun_ref_t<_Ret, _Tp> |
f6592a9e | 1386 | mem_fun_ref(_Ret (_Tp::*__f)() const) |
92ff3e43 | 1387 | { return const_mem_fun_ref_t<_Ret, _Tp>(__f); } |
f6592a9e | 1388 | |
bd1a56a0 | 1389 | template<typename _Ret, typename _Tp, typename _Arg> |
de196e5d | 1390 | _GLIBCXX11_DEPRECATED_SUGGEST("std::mem_fn") |
92ff3e43 | 1391 | inline mem_fun1_t<_Ret, _Tp, _Arg> |
f6592a9e | 1392 | mem_fun(_Ret (_Tp::*__f)(_Arg)) |
92ff3e43 | 1393 | { return mem_fun1_t<_Ret, _Tp, _Arg>(__f); } |
f6592a9e | 1394 | |
bd1a56a0 | 1395 | template<typename _Ret, typename _Tp, typename _Arg> |
de196e5d | 1396 | _GLIBCXX11_DEPRECATED_SUGGEST("std::mem_fn") |
92ff3e43 | 1397 | inline const_mem_fun1_t<_Ret, _Tp, _Arg> |
f6592a9e | 1398 | mem_fun(_Ret (_Tp::*__f)(_Arg) const) |
92ff3e43 | 1399 | { return const_mem_fun1_t<_Ret, _Tp, _Arg>(__f); } |
f6592a9e | 1400 | |
bd1a56a0 | 1401 | template<typename _Ret, typename _Tp, typename _Arg> |
de196e5d | 1402 | _GLIBCXX11_DEPRECATED_SUGGEST("std::mem_fn") |
92ff3e43 | 1403 | inline mem_fun1_ref_t<_Ret, _Tp, _Arg> |
f6592a9e | 1404 | mem_fun_ref(_Ret (_Tp::*__f)(_Arg)) |
92ff3e43 | 1405 | { return mem_fun1_ref_t<_Ret, _Tp, _Arg>(__f); } |
f6592a9e | 1406 | |
bd1a56a0 | 1407 | template<typename _Ret, typename _Tp, typename _Arg> |
de196e5d | 1408 | _GLIBCXX11_DEPRECATED_SUGGEST("std::mem_fn") |
92ff3e43 | 1409 | inline const_mem_fun1_ref_t<_Ret, _Tp, _Arg> |
f6592a9e | 1410 | mem_fun_ref(_Ret (_Tp::*__f)(_Arg) const) |
92ff3e43 | 1411 | { return const_mem_fun1_ref_t<_Ret, _Tp, _Arg>(__f); } |
de196e5d | 1412 | #pragma GCC diagnostic pop |
f6592a9e PC |
1413 | |
1414 | /** @} */ | |
ed6814f7 | 1415 | |
7ffa63df | 1416 | #ifdef __glibcxx_transparent_operators // C++ >= 14 |
d2b1a684 FD |
1417 | template<typename _Func, typename _SfinaeType, typename = __void_t<>> |
1418 | struct __has_is_transparent | |
1419 | { }; | |
1420 | ||
1421 | template<typename _Func, typename _SfinaeType> | |
1422 | struct __has_is_transparent<_Func, _SfinaeType, | |
1423 | __void_t<typename _Func::is_transparent>> | |
1424 | { typedef void type; }; | |
1425 | ||
1426 | template<typename _Func, typename _SfinaeType> | |
1427 | using __has_is_transparent_t | |
1428 | = typename __has_is_transparent<_Func, _SfinaeType>::type; | |
92381894 PP |
1429 | |
1430 | #if __cpp_concepts | |
1431 | template<typename _Func> | |
1432 | concept __transparent_comparator | |
1433 | = requires { typename _Func::is_transparent; }; | |
1434 | #endif | |
d2b1a684 FD |
1435 | #endif |
1436 | ||
12ffa228 BK |
1437 | _GLIBCXX_END_NAMESPACE_VERSION |
1438 | } // namespace | |
725dc051 | 1439 | |
734f5023 | 1440 | #if (__cplusplus < 201103L) || _GLIBCXX_USE_DEPRECATED |
40abbf1f BK |
1441 | # include <backward/binders.h> |
1442 | #endif | |
1443 | ||
046d30f4 | 1444 | #endif /* _STL_FUNCTION_H */ |