1 | |
2 | |
3 | |
4 | |
5 | |
6 | |
7 | |
8 | |
9 | |
10 | |
11 | |
12 | |
13 | |
14 | |
15 | |
16 | |
17 | |
18 | |
19 | |
20 | |
21 | |
22 | |
23 | |
24 | |
25 | |
26 | |
27 | |
28 | |
29 | |
30 | |
31 | |
32 | |
33 | |
34 | |
35 | |
36 | |
37 | |
38 | |
39 | |
40 | |
41 | |
42 | |
43 | |
44 | |
45 | |
46 | |
47 | |
48 | |
49 | |
50 | |
51 | |
52 | |
53 | |
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 | |
68 | |
69 | |
70 | |
71 | |
72 | |
73 | |
74 | |
75 | |
76 | |
77 | |
78 | |
79 | |
80 | |
81 | |
82 | |
83 | |
84 | |
85 | |
86 | |
87 | |
88 | |
89 | |
90 | |
91 | |
92 | |
93 | |
94 | |
95 | |
96 | |
97 | |
98 | |
99 | |
100 | |
101 | |
102 | |
103 | |
104 | template<typename _Arg, typename _Result> |
105 | struct unary_function |
106 | { |
107 | |
108 | typedef _Arg argument_type; |
109 | |
110 | |
111 | typedef _Result result_type; |
112 | }; |
113 | |
114 | |
115 | |
116 | |
117 | template<typename _Arg1, typename _Arg2, typename _Result> |
118 | struct binary_function |
119 | { |
120 | |
121 | typedef _Arg1 first_argument_type; |
122 | |
123 | |
124 | typedef _Arg2 second_argument_type; |
125 | |
126 | |
127 | typedef _Result result_type; |
128 | }; |
129 | |
130 | |
131 | |
132 | |
133 | |
134 | |
135 | |
136 | |
137 | |
138 | |
139 | |
140 | |
141 | |
142 | |
143 | #if __cplusplus > 201103L |
144 | struct __is_transparent; |
145 | |
146 | template<typename _Tp = void> |
147 | struct plus; |
148 | |
149 | template<typename _Tp = void> |
150 | struct minus; |
151 | |
152 | template<typename _Tp = void> |
153 | struct multiplies; |
154 | |
155 | template<typename _Tp = void> |
156 | struct divides; |
157 | |
158 | template<typename _Tp = void> |
159 | struct modulus; |
160 | |
161 | template<typename _Tp = void> |
162 | struct negate; |
163 | #endif |
164 | |
165 | |
166 | template<typename _Tp> |
167 | struct plus : public binary_function<_Tp, _Tp, _Tp> |
168 | { |
169 | _GLIBCXX14_CONSTEXPR |
170 | _Tp |
171 | operator()(const _Tp& __x, const _Tp& __y) const |
172 | { return __x + __y; } |
173 | }; |
174 | |
175 | |
176 | template<typename _Tp> |
177 | struct minus : public binary_function<_Tp, _Tp, _Tp> |
178 | { |
179 | _GLIBCXX14_CONSTEXPR |
180 | _Tp |
181 | operator()(const _Tp& __x, const _Tp& __y) const |
182 | { return __x - __y; } |
183 | }; |
184 | |
185 | |
186 | template<typename _Tp> |
187 | struct multiplies : public binary_function<_Tp, _Tp, _Tp> |
188 | { |
189 | _GLIBCXX14_CONSTEXPR |
190 | _Tp |
191 | operator()(const _Tp& __x, const _Tp& __y) const |
192 | { return __x * __y; } |
193 | }; |
194 | |
195 | |
196 | template<typename _Tp> |
197 | struct divides : public binary_function<_Tp, _Tp, _Tp> |
198 | { |
199 | _GLIBCXX14_CONSTEXPR |
200 | _Tp |
201 | operator()(const _Tp& __x, const _Tp& __y) const |
202 | { return __x / __y; } |
203 | }; |
204 | |
205 | |
206 | template<typename _Tp> |
207 | struct modulus : public binary_function<_Tp, _Tp, _Tp> |
208 | { |
209 | _GLIBCXX14_CONSTEXPR |
210 | _Tp |
211 | operator()(const _Tp& __x, const _Tp& __y) const |
212 | { return __x % __y; } |
213 | }; |
214 | |
215 | |
216 | template<typename _Tp> |
217 | struct negate : public unary_function<_Tp, _Tp> |
218 | { |
219 | _GLIBCXX14_CONSTEXPR |
220 | _Tp |
221 | operator()(const _Tp& __x) const |
222 | { return -__x; } |
223 | }; |
224 | |
225 | #if __cplusplus > 201103L |
226 | |
227 | #define __cpp_lib_transparent_operators 201510 |
228 | |
229 | template<> |
230 | struct plus<void> |
231 | { |
232 | template <typename _Tp, typename _Up> |
233 | _GLIBCXX14_CONSTEXPR |
234 | auto |
235 | operator()(_Tp&& __t, _Up&& __u) const |
236 | noexcept(noexcept(std::forward<_Tp>(__t) + std::forward<_Up>(__u))) |
237 | -> decltype(std::forward<_Tp>(__t) + std::forward<_Up>(__u)) |
238 | { return std::forward<_Tp>(__t) + std::forward<_Up>(__u); } |
239 | |
240 | typedef __is_transparent is_transparent; |
241 | }; |
242 | |
243 | |
244 | template<> |
245 | struct minus<void> |
246 | { |
247 | template <typename _Tp, typename _Up> |
248 | _GLIBCXX14_CONSTEXPR |
249 | auto |
250 | operator()(_Tp&& __t, _Up&& __u) const |
251 | noexcept(noexcept(std::forward<_Tp>(__t) - std::forward<_Up>(__u))) |
252 | -> decltype(std::forward<_Tp>(__t) - std::forward<_Up>(__u)) |
253 | { return std::forward<_Tp>(__t) - std::forward<_Up>(__u); } |
254 | |
255 | typedef __is_transparent is_transparent; |
256 | }; |
257 | |
258 | |
259 | template<> |
260 | struct multiplies<void> |
261 | { |
262 | template <typename _Tp, typename _Up> |
263 | _GLIBCXX14_CONSTEXPR |
264 | auto |
265 | operator()(_Tp&& __t, _Up&& __u) const |
266 | noexcept(noexcept(std::forward<_Tp>(__t) * std::forward<_Up>(__u))) |
267 | -> decltype(std::forward<_Tp>(__t) * std::forward<_Up>(__u)) |
268 | { return std::forward<_Tp>(__t) * std::forward<_Up>(__u); } |
269 | |
270 | typedef __is_transparent is_transparent; |
271 | }; |
272 | |
273 | |
274 | template<> |
275 | struct divides<void> |
276 | { |
277 | template <typename _Tp, typename _Up> |
278 | _GLIBCXX14_CONSTEXPR |
279 | auto |
280 | operator()(_Tp&& __t, _Up&& __u) const |
281 | noexcept(noexcept(std::forward<_Tp>(__t) / std::forward<_Up>(__u))) |
282 | -> decltype(std::forward<_Tp>(__t) / std::forward<_Up>(__u)) |
283 | { return std::forward<_Tp>(__t) / std::forward<_Up>(__u); } |
284 | |
285 | typedef __is_transparent is_transparent; |
286 | }; |
287 | |
288 | |
289 | template<> |
290 | struct modulus<void> |
291 | { |
292 | template <typename _Tp, typename _Up> |
293 | _GLIBCXX14_CONSTEXPR |
294 | auto |
295 | operator()(_Tp&& __t, _Up&& __u) const |
296 | noexcept(noexcept(std::forward<_Tp>(__t) % std::forward<_Up>(__u))) |
297 | -> decltype(std::forward<_Tp>(__t) % std::forward<_Up>(__u)) |
298 | { return std::forward<_Tp>(__t) % std::forward<_Up>(__u); } |
299 | |
300 | typedef __is_transparent is_transparent; |
301 | }; |
302 | |
303 | |
304 | template<> |
305 | struct negate<void> |
306 | { |
307 | template <typename _Tp> |
308 | _GLIBCXX14_CONSTEXPR |
309 | auto |
310 | operator()(_Tp&& __t) const |
311 | noexcept(noexcept(-std::forward<_Tp>(__t))) |
312 | -> decltype(-std::forward<_Tp>(__t)) |
313 | { return -std::forward<_Tp>(__t); } |
314 | |
315 | typedef __is_transparent is_transparent; |
316 | }; |
317 | #endif |
318 | |
319 | |
320 | |
321 | |
322 | |
323 | |
324 | |
325 | |
326 | |
327 | |
328 | |
329 | #if __cplusplus > 201103L |
330 | template<typename _Tp = void> |
331 | struct equal_to; |
332 | |
333 | template<typename _Tp = void> |
334 | struct not_equal_to; |
335 | |
336 | template<typename _Tp = void> |
337 | struct greater; |
338 | |
339 | template<typename _Tp = void> |
340 | struct less; |
341 | |
342 | template<typename _Tp = void> |
343 | struct greater_equal; |
344 | |
345 | template<typename _Tp = void> |
346 | struct less_equal; |
347 | #endif |
348 | |
349 | |
350 | template<typename _Tp> |
351 | struct equal_to : public binary_function<_Tp, _Tp, bool> |
352 | { |
353 | _GLIBCXX14_CONSTEXPR |
354 | bool |
355 | operator()(const _Tp& __x, const _Tp& __y) const |
356 | { return __x == __y; } |
357 | }; |
358 | |
359 | |
360 | template<typename _Tp> |
361 | struct not_equal_to : public binary_function<_Tp, _Tp, bool> |
362 | { |
363 | _GLIBCXX14_CONSTEXPR |
364 | bool |
365 | operator()(const _Tp& __x, const _Tp& __y) const |
366 | { return __x != __y; } |
367 | }; |
368 | |
369 | |
370 | template<typename _Tp> |
371 | struct greater : public binary_function<_Tp, _Tp, bool> |
372 | { |
373 | _GLIBCXX14_CONSTEXPR |
374 | bool |
375 | operator()(const _Tp& __x, const _Tp& __y) const |
376 | { return __x > __y; } |
377 | }; |
378 | |
379 | |
380 | template<typename _Tp> |
381 | struct less : public binary_function<_Tp, _Tp, bool> |
382 | { |
383 | _GLIBCXX14_CONSTEXPR |
384 | bool |
385 | operator()(const _Tp& __x, const _Tp& __y) const |
386 | { return __x < __y; } |
387 | }; |
388 | |
389 | |
390 | template<typename _Tp> |
391 | struct greater_equal : public binary_function<_Tp, _Tp, bool> |
392 | { |
393 | _GLIBCXX14_CONSTEXPR |
394 | bool |
395 | operator()(const _Tp& __x, const _Tp& __y) const |
396 | { return __x >= __y; } |
397 | }; |
398 | |
399 | |
400 | template<typename _Tp> |
401 | struct less_equal : public binary_function<_Tp, _Tp, bool> |
402 | { |
403 | _GLIBCXX14_CONSTEXPR |
404 | bool |
405 | operator()(const _Tp& __x, const _Tp& __y) const |
406 | { return __x <= __y; } |
407 | }; |
408 | |
409 | #if __cplusplus > 201103L |
410 | |
411 | template<> |
412 | struct equal_to<void> |
413 | { |
414 | template <typename _Tp, typename _Up> |
415 | _GLIBCXX14_CONSTEXPR |
416 | auto |
417 | operator()(_Tp&& __t, _Up&& __u) const |
418 | noexcept(noexcept(std::forward<_Tp>(__t) == std::forward<_Up>(__u))) |
419 | -> decltype(std::forward<_Tp>(__t) == std::forward<_Up>(__u)) |
420 | { return std::forward<_Tp>(__t) == std::forward<_Up>(__u); } |
421 | |
422 | typedef __is_transparent is_transparent; |
423 | }; |
424 | |
425 | |
426 | template<> |
427 | struct not_equal_to<void> |
428 | { |
429 | template <typename _Tp, typename _Up> |
430 | _GLIBCXX14_CONSTEXPR |
431 | auto |
432 | operator()(_Tp&& __t, _Up&& __u) const |
433 | noexcept(noexcept(std::forward<_Tp>(__t) != std::forward<_Up>(__u))) |
434 | -> decltype(std::forward<_Tp>(__t) != std::forward<_Up>(__u)) |
435 | { return std::forward<_Tp>(__t) != std::forward<_Up>(__u); } |
436 | |
437 | typedef __is_transparent is_transparent; |
438 | }; |
439 | |
440 | |
441 | template<> |
442 | struct greater<void> |
443 | { |
444 | template <typename _Tp, typename _Up> |
445 | _GLIBCXX14_CONSTEXPR |
446 | auto |
447 | operator()(_Tp&& __t, _Up&& __u) const |
448 | noexcept(noexcept(std::forward<_Tp>(__t) > std::forward<_Up>(__u))) |
449 | -> decltype(std::forward<_Tp>(__t) > std::forward<_Up>(__u)) |
450 | { return std::forward<_Tp>(__t) > std::forward<_Up>(__u); } |
451 | |
452 | typedef __is_transparent is_transparent; |
453 | }; |
454 | |
455 | |
456 | template<> |
457 | struct less<void> |
458 | { |
459 | template <typename _Tp, typename _Up> |
460 | _GLIBCXX14_CONSTEXPR |
461 | auto |
462 | operator()(_Tp&& __t, _Up&& __u) const |
463 | noexcept(noexcept(std::forward<_Tp>(__t) < std::forward<_Up>(__u))) |
464 | -> decltype(std::forward<_Tp>(__t) < std::forward<_Up>(__u)) |
465 | { return std::forward<_Tp>(__t) < std::forward<_Up>(__u); } |
466 | |
467 | typedef __is_transparent is_transparent; |
468 | }; |
469 | |
470 | |
471 | template<> |
472 | struct greater_equal<void> |
473 | { |
474 | template <typename _Tp, typename _Up> |
475 | _GLIBCXX14_CONSTEXPR |
476 | auto |
477 | operator()(_Tp&& __t, _Up&& __u) const |
478 | noexcept(noexcept(std::forward<_Tp>(__t) >= std::forward<_Up>(__u))) |
479 | -> decltype(std::forward<_Tp>(__t) >= std::forward<_Up>(__u)) |
480 | { return std::forward<_Tp>(__t) >= std::forward<_Up>(__u); } |
481 | |
482 | typedef __is_transparent is_transparent; |
483 | }; |
484 | |
485 | |
486 | template<> |
487 | struct less_equal<void> |
488 | { |
489 | template <typename _Tp, typename _Up> |
490 | _GLIBCXX14_CONSTEXPR |
491 | auto |
492 | operator()(_Tp&& __t, _Up&& __u) const |
493 | noexcept(noexcept(std::forward<_Tp>(__t) <= std::forward<_Up>(__u))) |
494 | -> decltype(std::forward<_Tp>(__t) <= std::forward<_Up>(__u)) |
495 | { return std::forward<_Tp>(__t) <= std::forward<_Up>(__u); } |
496 | |
497 | typedef __is_transparent is_transparent; |
498 | }; |
499 | #endif |
500 | |
501 | |
502 | |
503 | |
504 | |
505 | |
506 | |
507 | |
508 | |
509 | |
510 | |
511 | #if __cplusplus > 201103L |
512 | template<typename _Tp = void> |
513 | struct logical_and; |
514 | |
515 | template<typename _Tp = void> |
516 | struct logical_or; |
517 | |
518 | template<typename _Tp = void> |
519 | struct logical_not; |
520 | #endif |
521 | |
522 | |
523 | template<typename _Tp> |
524 | struct logical_and : public binary_function<_Tp, _Tp, bool> |
525 | { |
526 | _GLIBCXX14_CONSTEXPR |
527 | bool |
528 | operator()(const _Tp& __x, const _Tp& __y) const |
529 | { return __x && __y; } |
530 | }; |
531 | |
532 | |
533 | template<typename _Tp> |
534 | struct logical_or : public binary_function<_Tp, _Tp, bool> |
535 | { |
536 | _GLIBCXX14_CONSTEXPR |
537 | bool |
538 | operator()(const _Tp& __x, const _Tp& __y) const |
539 | { return __x || __y; } |
540 | }; |
541 | |
542 | |
543 | template<typename _Tp> |
544 | struct logical_not : public unary_function<_Tp, bool> |
545 | { |
546 | _GLIBCXX14_CONSTEXPR |
547 | bool |
548 | operator()(const _Tp& __x) const |
549 | { return !__x; } |
550 | }; |
551 | |
552 | #if __cplusplus > 201103L |
553 | |
554 | template<> |
555 | struct logical_and<void> |
556 | { |
557 | template <typename _Tp, typename _Up> |
558 | _GLIBCXX14_CONSTEXPR |
559 | auto |
560 | operator()(_Tp&& __t, _Up&& __u) const |
561 | noexcept(noexcept(std::forward<_Tp>(__t) && std::forward<_Up>(__u))) |
562 | -> decltype(std::forward<_Tp>(__t) && std::forward<_Up>(__u)) |
563 | { return std::forward<_Tp>(__t) && std::forward<_Up>(__u); } |
564 | |
565 | typedef __is_transparent is_transparent; |
566 | }; |
567 | |
568 | |
569 | template<> |
570 | struct logical_or<void> |
571 | { |
572 | template <typename _Tp, typename _Up> |
573 | _GLIBCXX14_CONSTEXPR |
574 | auto |
575 | operator()(_Tp&& __t, _Up&& __u) const |
576 | noexcept(noexcept(std::forward<_Tp>(__t) || std::forward<_Up>(__u))) |
577 | -> decltype(std::forward<_Tp>(__t) || std::forward<_Up>(__u)) |
578 | { return std::forward<_Tp>(__t) || std::forward<_Up>(__u); } |
579 | |
580 | typedef __is_transparent is_transparent; |
581 | }; |
582 | |
583 | |
584 | template<> |
585 | struct logical_not<void> |
586 | { |
587 | template <typename _Tp> |
588 | _GLIBCXX14_CONSTEXPR |
589 | auto |
590 | operator()(_Tp&& __t) const |
591 | noexcept(noexcept(!std::forward<_Tp>(__t))) |
592 | -> decltype(!std::forward<_Tp>(__t)) |
593 | { return !std::forward<_Tp>(__t); } |
594 | |
595 | typedef __is_transparent is_transparent; |
596 | }; |
597 | #endif |
598 | |
599 | |
600 | #if __cplusplus > 201103L |
601 | template<typename _Tp = void> |
602 | struct bit_and; |
603 | |
604 | template<typename _Tp = void> |
605 | struct bit_or; |
606 | |
607 | template<typename _Tp = void> |
608 | struct bit_xor; |
609 | |
610 | template<typename _Tp = void> |
611 | struct bit_not; |
612 | #endif |
613 | |
614 | |
615 | |
616 | template<typename _Tp> |
617 | struct bit_and : public binary_function<_Tp, _Tp, _Tp> |
618 | { |
619 | _GLIBCXX14_CONSTEXPR |
620 | _Tp |
621 | operator()(const _Tp& __x, const _Tp& __y) const |
622 | { return __x & __y; } |
623 | }; |
624 | |
625 | template<typename _Tp> |
626 | struct bit_or : public binary_function<_Tp, _Tp, _Tp> |
627 | { |
628 | _GLIBCXX14_CONSTEXPR |
629 | _Tp |
630 | operator()(const _Tp& __x, const _Tp& __y) const |
631 | { return __x | __y; } |
632 | }; |
633 | |
634 | template<typename _Tp> |
635 | struct bit_xor : public binary_function<_Tp, _Tp, _Tp> |
636 | { |
637 | _GLIBCXX14_CONSTEXPR |
638 | _Tp |
639 | operator()(const _Tp& __x, const _Tp& __y) const |
640 | { return __x ^ __y; } |
641 | }; |
642 | |
643 | template<typename _Tp> |
644 | struct bit_not : public unary_function<_Tp, _Tp> |
645 | { |
646 | _GLIBCXX14_CONSTEXPR |
647 | _Tp |
648 | operator()(const _Tp& __x) const |
649 | { return ~__x; } |
650 | }; |
651 | |
652 | #if __cplusplus > 201103L |
653 | template <> |
654 | struct bit_and<void> |
655 | { |
656 | template <typename _Tp, typename _Up> |
657 | _GLIBCXX14_CONSTEXPR |
658 | auto |
659 | operator()(_Tp&& __t, _Up&& __u) const |
660 | noexcept(noexcept(std::forward<_Tp>(__t) & std::forward<_Up>(__u))) |
661 | -> decltype(std::forward<_Tp>(__t) & std::forward<_Up>(__u)) |
662 | { return std::forward<_Tp>(__t) & std::forward<_Up>(__u); } |
663 | |
664 | typedef __is_transparent is_transparent; |
665 | }; |
666 | |
667 | template <> |
668 | struct bit_or<void> |
669 | { |
670 | template <typename _Tp, typename _Up> |
671 | _GLIBCXX14_CONSTEXPR |
672 | auto |
673 | operator()(_Tp&& __t, _Up&& __u) const |
674 | noexcept(noexcept(std::forward<_Tp>(__t) | std::forward<_Up>(__u))) |
675 | -> decltype(std::forward<_Tp>(__t) | std::forward<_Up>(__u)) |
676 | { return std::forward<_Tp>(__t) | std::forward<_Up>(__u); } |
677 | |
678 | typedef __is_transparent is_transparent; |
679 | }; |
680 | |
681 | template <> |
682 | struct bit_xor<void> |
683 | { |
684 | template <typename _Tp, typename _Up> |
685 | _GLIBCXX14_CONSTEXPR |
686 | auto |
687 | operator()(_Tp&& __t, _Up&& __u) const |
688 | noexcept(noexcept(std::forward<_Tp>(__t) ^ std::forward<_Up>(__u))) |
689 | -> decltype(std::forward<_Tp>(__t) ^ std::forward<_Up>(__u)) |
690 | { return std::forward<_Tp>(__t) ^ std::forward<_Up>(__u); } |
691 | |
692 | typedef __is_transparent is_transparent; |
693 | }; |
694 | |
695 | template <> |
696 | struct bit_not<void> |
697 | { |
698 | template <typename _Tp> |
699 | _GLIBCXX14_CONSTEXPR |
700 | auto |
701 | operator()(_Tp&& __t) const |
702 | noexcept(noexcept(~std::forward<_Tp>(__t))) |
703 | -> decltype(~std::forward<_Tp>(__t)) |
704 | { return ~std::forward<_Tp>(__t); } |
705 | |
706 | typedef __is_transparent is_transparent; |
707 | }; |
708 | #endif |
709 | |
710 | |
711 | |
712 | |
713 | |
714 | |
715 | |
716 | |
717 | |
718 | |
719 | |
720 | |
721 | |
722 | |
723 | |
724 | |
725 | |
726 | |
727 | |
728 | |
729 | |
730 | |
731 | |
732 | |
733 | |
734 | |
735 | |
736 | |
737 | |
738 | |
739 | |
740 | template<typename _Predicate> |
741 | class unary_negate |
742 | : public unary_function<typename _Predicate::argument_type, bool> |
743 | { |
744 | protected: |
745 | _Predicate _M_pred; |
746 | |
747 | public: |
748 | _GLIBCXX14_CONSTEXPR |
749 | explicit |
750 | unary_negate(const _Predicate& __x) : _M_pred(__x) { } |
751 | |
752 | _GLIBCXX14_CONSTEXPR |
753 | bool |
754 | operator()(const typename _Predicate::argument_type& __x) const |
755 | { return !_M_pred(__x); } |
756 | }; |
757 | |
758 | |
759 | template<typename _Predicate> |
760 | _GLIBCXX14_CONSTEXPR |
761 | inline unary_negate<_Predicate> |
762 | not1(const _Predicate& __pred) |
763 | { return unary_negate<_Predicate>(__pred); } |
764 | |
765 | |
766 | template<typename _Predicate> |
767 | class binary_negate |
768 | : public binary_function<typename _Predicate::first_argument_type, |
769 | typename _Predicate::second_argument_type, bool> |
770 | { |
771 | protected: |
772 | _Predicate _M_pred; |
773 | |
774 | public: |
775 | _GLIBCXX14_CONSTEXPR |
776 | explicit |
777 | binary_negate(const _Predicate& __x) : _M_pred(__x) { } |
778 | |
779 | _GLIBCXX14_CONSTEXPR |
780 | bool |
781 | operator()(const typename _Predicate::first_argument_type& __x, |
782 | const typename _Predicate::second_argument_type& __y) const |
783 | { return !_M_pred(__x, __y); } |
784 | }; |
785 | |
786 | |
787 | template<typename _Predicate> |
788 | _GLIBCXX14_CONSTEXPR |
789 | inline binary_negate<_Predicate> |
790 | not2(const _Predicate& __pred) |
791 | { return binary_negate<_Predicate>(__pred); } |
792 | |
793 | |
794 | |
795 | |
796 | |
797 | |
798 | |
799 | |
800 | |
801 | |
802 | |
803 | |
804 | |
805 | |
806 | |
807 | |
808 | |
809 | |
810 | |
811 | |
812 | |
813 | |
814 | |
815 | |
816 | |
817 | template<typename _Arg, typename _Result> |
818 | class pointer_to_unary_function : public unary_function<_Arg, _Result> |
819 | { |
820 | protected: |
821 | _Result (*_M_ptr)(_Arg); |
822 | |
823 | public: |
824 | pointer_to_unary_function() { } |
825 | |
826 | explicit |
827 | pointer_to_unary_function(_Result (*__x)(_Arg)) |
828 | : _M_ptr(__x) { } |
829 | |
830 | _Result |
831 | operator()(_Arg __x) const |
832 | { return _M_ptr(__x); } |
833 | }; |
834 | |
835 | |
836 | template<typename _Arg, typename _Result> |
837 | inline pointer_to_unary_function<_Arg, _Result> |
838 | ptr_fun(_Result (*__x)(_Arg)) |
839 | { return pointer_to_unary_function<_Arg, _Result>(__x); } |
840 | |
841 | |
842 | template<typename _Arg1, typename _Arg2, typename _Result> |
843 | class pointer_to_binary_function |
844 | : public binary_function<_Arg1, _Arg2, _Result> |
845 | { |
846 | protected: |
847 | _Result (*_M_ptr)(_Arg1, _Arg2); |
848 | |
849 | public: |
850 | pointer_to_binary_function() { } |
851 | |
852 | explicit |
853 | pointer_to_binary_function(_Result (*__x)(_Arg1, _Arg2)) |
854 | : _M_ptr(__x) { } |
855 | |
856 | _Result |
857 | operator()(_Arg1 __x, _Arg2 __y) const |
858 | { return _M_ptr(__x, __y); } |
859 | }; |
860 | |
861 | |
862 | template<typename _Arg1, typename _Arg2, typename _Result> |
863 | inline pointer_to_binary_function<_Arg1, _Arg2, _Result> |
864 | ptr_fun(_Result (*__x)(_Arg1, _Arg2)) |
865 | { return pointer_to_binary_function<_Arg1, _Arg2, _Result>(__x); } |
866 | |
867 | |
868 | template<typename _Tp> |
869 | struct _Identity |
870 | : public unary_function<_Tp,_Tp> |
871 | { |
872 | _Tp& |
873 | operator()(_Tp& __x) const |
874 | { return __x; } |
875 | |
876 | const _Tp& |
877 | operator()(const _Tp& __x) const |
878 | { return __x; } |
879 | }; |
880 | |
881 | template<typename _Pair> |
882 | struct _Select1st |
883 | : public unary_function<_Pair, typename _Pair::first_type> |
884 | { |
885 | typename _Pair::first_type& |
886 | operator()(_Pair& __x) const |
887 | { return __x.first; } |
888 | |
889 | const typename _Pair::first_type& |
890 | operator()(const _Pair& __x) const |
891 | { return __x.first; } |
892 | |
893 | #if __cplusplus >= 201103L |
894 | template<typename _Pair2> |
895 | typename _Pair2::first_type& |
896 | operator()(_Pair2& __x) const |
897 | { return __x.first; } |
898 | |
899 | template<typename _Pair2> |
900 | const typename _Pair2::first_type& |
901 | operator()(const _Pair2& __x) const |
902 | { return __x.first; } |
903 | #endif |
904 | }; |
905 | |
906 | template<typename _Pair> |
907 | struct _Select2nd |
908 | : public unary_function<_Pair, typename _Pair::second_type> |
909 | { |
910 | typename _Pair::second_type& |
911 | operator()(_Pair& __x) const |
912 | { return __x.second; } |
913 | |
914 | const typename _Pair::second_type& |
915 | operator()(const _Pair& __x) const |
916 | { return __x.second; } |
917 | }; |
918 | |
919 | |
920 | |
921 | |
922 | |
923 | |
924 | |
925 | |
926 | |
927 | |
928 | |
929 | |
930 | |
931 | |
932 | |
933 | |
934 | |
935 | |
936 | |
937 | template<typename _Ret, typename _Tp> |
938 | class mem_fun_t : public unary_function<_Tp*, _Ret> |
939 | { |
940 | public: |
941 | explicit |
942 | mem_fun_t(_Ret (_Tp::*__pf)()) |
943 | : _M_f(__pf) { } |
944 | |
945 | _Ret |
946 | operator()(_Tp* __p) const |
947 | { return (__p->*_M_f)(); } |
948 | |
949 | private: |
950 | _Ret (_Tp::*_M_f)(); |
951 | }; |
952 | |
953 | |
954 | |
955 | template<typename _Ret, typename _Tp> |
956 | class const_mem_fun_t : public unary_function<const _Tp*, _Ret> |
957 | { |
958 | public: |
959 | explicit |
960 | const_mem_fun_t(_Ret (_Tp::*__pf)() const) |
961 | : _M_f(__pf) { } |
962 | |
963 | _Ret |
964 | operator()(const _Tp* __p) const |
965 | { return (__p->*_M_f)(); } |
966 | |
967 | private: |
968 | _Ret (_Tp::*_M_f)() const; |
969 | }; |
970 | |
971 | |
972 | |
973 | template<typename _Ret, typename _Tp> |
974 | class mem_fun_ref_t : public unary_function<_Tp, _Ret> |
975 | { |
976 | public: |
977 | explicit |
978 | mem_fun_ref_t(_Ret (_Tp::*__pf)()) |
979 | : _M_f(__pf) { } |
980 | |
981 | _Ret |
982 | operator()(_Tp& __r) const |
983 | { return (__r.*_M_f)(); } |
984 | |
985 | private: |
986 | _Ret (_Tp::*_M_f)(); |
987 | }; |
988 | |
989 | |
990 | |
991 | template<typename _Ret, typename _Tp> |
992 | class const_mem_fun_ref_t : public unary_function<_Tp, _Ret> |
993 | { |
994 | public: |
995 | explicit |
996 | const_mem_fun_ref_t(_Ret (_Tp::*__pf)() const) |
997 | : _M_f(__pf) { } |
998 | |
999 | _Ret |
1000 | operator()(const _Tp& __r) const |
1001 | { return (__r.*_M_f)(); } |
1002 | |
1003 | private: |
1004 | _Ret (_Tp::*_M_f)() const; |
1005 | }; |
1006 | |
1007 | |
1008 | |
1009 | template<typename _Ret, typename _Tp, typename _Arg> |
1010 | class mem_fun1_t : public binary_function<_Tp*, _Arg, _Ret> |
1011 | { |
1012 | public: |
1013 | explicit |
1014 | mem_fun1_t(_Ret (_Tp::*__pf)(_Arg)) |
1015 | : _M_f(__pf) { } |
1016 | |
1017 | _Ret |
1018 | operator()(_Tp* __p, _Arg __x) const |
1019 | { return (__p->*_M_f)(__x); } |
1020 | |
1021 | private: |
1022 | _Ret (_Tp::*_M_f)(_Arg); |
1023 | }; |
1024 | |
1025 | |
1026 | |
1027 | template<typename _Ret, typename _Tp, typename _Arg> |
1028 | class const_mem_fun1_t : public binary_function<const _Tp*, _Arg, _Ret> |
1029 | { |
1030 | public: |
1031 | explicit |
1032 | const_mem_fun1_t(_Ret (_Tp::*__pf)(_Arg) const) |
1033 | : _M_f(__pf) { } |
1034 | |
1035 | _Ret |
1036 | operator()(const _Tp* __p, _Arg __x) const |
1037 | { return (__p->*_M_f)(__x); } |
1038 | |
1039 | private: |
1040 | _Ret (_Tp::*_M_f)(_Arg) const; |
1041 | }; |
1042 | |
1043 | |
1044 | |
1045 | template<typename _Ret, typename _Tp, typename _Arg> |
1046 | class mem_fun1_ref_t : public binary_function<_Tp, _Arg, _Ret> |
1047 | { |
1048 | public: |
1049 | explicit |
1050 | mem_fun1_ref_t(_Ret (_Tp::*__pf)(_Arg)) |
1051 | : _M_f(__pf) { } |
1052 | |
1053 | _Ret |
1054 | operator()(_Tp& __r, _Arg __x) const |
1055 | { return (__r.*_M_f)(__x); } |
1056 | |
1057 | private: |
1058 | _Ret (_Tp::*_M_f)(_Arg); |
1059 | }; |
1060 | |
1061 | |
1062 | |
1063 | template<typename _Ret, typename _Tp, typename _Arg> |
1064 | class const_mem_fun1_ref_t : public binary_function<_Tp, _Arg, _Ret> |
1065 | { |
1066 | public: |
1067 | explicit |
1068 | const_mem_fun1_ref_t(_Ret (_Tp::*__pf)(_Arg) const) |
1069 | : _M_f(__pf) { } |
1070 | |
1071 | _Ret |
1072 | operator()(const _Tp& __r, _Arg __x) const |
1073 | { return (__r.*_M_f)(__x); } |
1074 | |
1075 | private: |
1076 | _Ret (_Tp::*_M_f)(_Arg) const; |
1077 | }; |
1078 | |
1079 | |
1080 | |
1081 | template<typename _Ret, typename _Tp> |
1082 | inline mem_fun_t<_Ret, _Tp> |
1083 | mem_fun(_Ret (_Tp::*__f)()) |
1084 | { return mem_fun_t<_Ret, _Tp>(__f); } |
1085 | |
1086 | template<typename _Ret, typename _Tp> |
1087 | inline const_mem_fun_t<_Ret, _Tp> |
1088 | mem_fun(_Ret (_Tp::*__f)() const) |
1089 | { return const_mem_fun_t<_Ret, _Tp>(__f); } |
1090 | |
1091 | template<typename _Ret, typename _Tp> |
1092 | inline mem_fun_ref_t<_Ret, _Tp> |
1093 | mem_fun_ref(_Ret (_Tp::*__f)()) |
1094 | { return mem_fun_ref_t<_Ret, _Tp>(__f); } |
1095 | |
1096 | template<typename _Ret, typename _Tp> |
1097 | inline const_mem_fun_ref_t<_Ret, _Tp> |
1098 | mem_fun_ref(_Ret (_Tp::*__f)() const) |
1099 | { return const_mem_fun_ref_t<_Ret, _Tp>(__f); } |
1100 | |
1101 | template<typename _Ret, typename _Tp, typename _Arg> |
1102 | inline mem_fun1_t<_Ret, _Tp, _Arg> |
1103 | mem_fun(_Ret (_Tp::*__f)(_Arg)) |
1104 | { return mem_fun1_t<_Ret, _Tp, _Arg>(__f); } |
1105 | |
1106 | template<typename _Ret, typename _Tp, typename _Arg> |
1107 | inline const_mem_fun1_t<_Ret, _Tp, _Arg> |
1108 | mem_fun(_Ret (_Tp::*__f)(_Arg) const) |
1109 | { return const_mem_fun1_t<_Ret, _Tp, _Arg>(__f); } |
1110 | |
1111 | template<typename _Ret, typename _Tp, typename _Arg> |
1112 | inline mem_fun1_ref_t<_Ret, _Tp, _Arg> |
1113 | mem_fun_ref(_Ret (_Tp::*__f)(_Arg)) |
1114 | { return mem_fun1_ref_t<_Ret, _Tp, _Arg>(__f); } |
1115 | |
1116 | template<typename _Ret, typename _Tp, typename _Arg> |
1117 | inline const_mem_fun1_ref_t<_Ret, _Tp, _Arg> |
1118 | mem_fun_ref(_Ret (_Tp::*__f)(_Arg) const) |
1119 | { return const_mem_fun1_ref_t<_Ret, _Tp, _Arg>(__f); } |
1120 | |
1121 | |
1122 | |
1123 | _GLIBCXX_END_NAMESPACE_VERSION |
1124 | } |
1125 | |
1126 | #if (__cplusplus < 201103L) || _GLIBCXX_USE_DEPRECATED |
1127 | # include <backward/binders.h> |
1128 | #endif |
1129 | |
1130 | #endif |
1131 | |