]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/phoenix/include/boost/phoenix/stl/algorithm/transformation.hpp
bump version to 12.2.2-pve1
[ceph.git] / ceph / src / boost / libs / phoenix / include / boost / phoenix / stl / algorithm / transformation.hpp
1 // Copyright 2005 Daniel Wallin.
2 // Copyright 2005 Joel de Guzman.
3 // Copyright 2005 Dan Marsden.
4 // Copyright 2015 John Fletcher.
5 //
6 // Use, modification and distribution is subject to the Boost Software
7 // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
8 // http://www.boost.org/LICENSE_1_0.txt)
9 //
10 // Modeled after range_ex, Copyright 2004 Eric Niebler
11
12 #ifndef BOOST_PHOENIX_ALGORITHM_TRANSFORMATION_HPP
13 #define BOOST_PHOENIX_ALGORITHM_TRANSFORMATION_HPP
14
15 #include <algorithm>
16 #include <numeric>
17
18 #include <boost/phoenix/core/limits.hpp>
19 #include <boost/phoenix/stl/algorithm/detail/has_sort.hpp>
20 #include <boost/phoenix/stl/algorithm/detail/has_remove.hpp>
21 #include <boost/phoenix/stl/algorithm/detail/has_remove_if.hpp>
22 #include <boost/phoenix/stl/algorithm/detail/has_unique.hpp>
23 #include <boost/phoenix/stl/algorithm/detail/has_reverse.hpp>
24 #include <boost/phoenix/stl/algorithm/detail/has_sort.hpp>
25
26 #include <boost/phoenix/stl/algorithm/detail/begin.hpp>
27 #include <boost/phoenix/stl/algorithm/detail/end.hpp>
28 #include <boost/phoenix/stl/algorithm/detail/decay_array.hpp>
29
30 #include <boost/phoenix/function/adapt_callable.hpp>
31
32 //#include <boost/range/result_iterator.hpp> is deprecated
33 #include <boost/range/iterator.hpp>
34 #include <boost/range/difference_type.hpp>
35
36 #include <boost/mpl/if.hpp>
37
38 #include <boost/type_traits/is_void.hpp>
39
40 namespace boost { namespace phoenix { namespace impl
41 {
42 struct swap
43 {
44 typedef void result_type;
45
46 template <class A, class B>
47 void operator()(A& a, B& b) const
48 {
49 using std::swap;
50 swap(a, b);
51 }
52 };
53
54 struct copy
55 {
56 template <typename Sig>
57 struct result;
58
59 template<typename This, class R, class I>
60 struct result<This(R&, I)>
61 : detail::decay_array<I>
62 {};
63
64 template<class R, class I>
65 typename detail::decay_array<I>::type
66 operator()(R& r, I i) const
67 {
68 return std::copy(detail::begin_(r), detail::end_(r), i);
69 }
70 };
71
72 struct copy_backward
73 {
74 template <typename Sig>
75 struct result;
76
77 template<typename This, class R, class I>
78 struct result<This(R&, I)>
79 : result<This(R&, I const &)>
80 {};
81
82 template<typename This, class R, class I>
83 struct result<This(R&, I &)>
84 {
85 typedef I type;
86 };
87
88 template<class R, class I>
89 I operator()(R& r, I & i) const
90 {
91 return std::copy_backward(detail::begin_(r), detail::end_(r), i);
92 }
93
94 template<class R, class I>
95 I const operator()(R& r, I const & i) const
96 {
97 return std::copy_backward(detail::begin_(r), detail::end_(r), i);
98 }
99 };
100
101 struct transform
102 {
103 template <typename Sig>
104 struct result;
105
106 template<typename This, class R, class OutorI1, class ForOut>
107 struct result<This(R&, OutorI1, ForOut)>
108 : detail::decay_array<OutorI1>
109 {
110 };
111
112 template<typename This, class R, class OutorI1, class ForOut, class BinF>
113 struct result<This(R&, OutorI1, ForOut, BinF)>
114 : detail::decay_array<ForOut>
115 {
116 };
117
118 template<class R, class O, class F>
119 typename result<transform(R&,O,F)>::type
120 operator()(R& r, O o, F f) const
121 {
122 return std::transform(detail::begin_(r), detail::end_(r), o, f);
123 }
124
125 template<class R, class I, class O, class F>
126 typename result<transform(R&,I,O,F)>::type
127 operator()(R& r, I i, O o, F f) const
128 {
129 return std::transform(detail::begin_(r), detail::end_(r), i, o, f);
130 }
131 };
132
133 struct replace
134 {
135 typedef void result_type;
136
137 template<class R, class T>
138 void operator()(R& r, T const& what, T const& with) const
139 {
140 std::replace(detail::begin_(r), detail::end_(r), what, with);
141 }
142 };
143
144 struct replace_if
145 {
146 typedef void result_type;
147
148 template<class R, class P, class T>
149 void operator()(R& r, P p, T const& with) const
150 {
151 std::replace_if(detail::begin_(r), detail::end_(r), p, with);
152 }
153 };
154
155 struct replace_copy
156 {
157 template <typename Sig>
158 struct result;
159
160 template<typename This, class R, class O, class T, class T2>
161 struct result<This(R&, O, T&, T2&)>
162 : detail::decay_array<O>
163 {};
164
165 template<class R, class O, class T>
166 typename detail::decay_array<O>::type
167 operator()(R& r, O o, T const& what, T const& with) const
168 {
169 return std::replace_copy(detail::begin_(r), detail::end_(r), o, what, with);
170 }
171 };
172
173 struct replace_copy_if
174 {
175 template <typename Sig>
176 struct result;
177
178 template<typename This, class R, class O, class P, class T>
179 struct result<This(R&, O, P, T&)>
180 : detail::decay_array<O>
181 {};
182
183 template<class R, class O, class P, class T>
184 typename detail::decay_array<O>::type
185 operator()(R& r, O o, P p, T const& with) const
186 {
187 return std::replace_copy_if(detail::begin_(r), detail::end_(r), o, p, with);
188 }
189 };
190
191 struct fill
192 {
193 typedef void result_type;
194
195 template<class R, class T>
196 void operator()(R& r, T const& x) const
197 {
198 std::fill(detail::begin_(r), detail::end_(r), x);
199 }
200 };
201
202 struct fill_n
203 {
204 typedef void result_type;
205
206 template<class R, class N, class T>
207 void operator()(R& r, N n, T const& x) const
208 {
209 std::fill_n(detail::begin_(r), n, x);
210 }
211 };
212
213 struct generate
214 {
215 typedef void result_type;
216
217 template<class R, class G>
218 void operator()(R& r, G const & g) const
219 {
220 std::generate(detail::begin_(r), detail::end_(r), g);
221 }
222 };
223
224 struct generate_n
225 {
226 typedef void result_type;
227
228 template<class R, class N, class G>
229 void operator()(R& r, N n, G g) const
230 {
231 std::generate_n(detail::begin_(r), n, g);
232 }
233 };
234
235 struct remove
236 {
237 template <typename Sig>
238 struct result;
239
240 template<typename This, class R, class T>
241 struct result<This(R&, T&)>
242 : range_iterator<R>
243 {
244 };
245
246 template<class R, class T>
247 typename range_iterator<R>::type
248 execute(R& r, T const& x, mpl::true_) const
249 {
250 r.remove(x);
251 return detail::end_(r);
252 }
253
254 template<class R, class T>
255 typename range_iterator<R>::type
256 execute(R& r, T const& x, mpl::false_) const
257 {
258 return std::remove(detail::begin_(r), detail::end_(r), x);
259 }
260
261 template<class R, class T>
262 typename range_iterator<R>::type
263 operator()(R& r, T const& x) const
264 {
265 return execute(r, x, has_remove<R>());
266 }
267 };
268
269 struct remove_if
270 {
271 template <typename Sig>
272 struct result;
273
274 template <typename This, class R, class P>
275 struct result<This(R&,P)>
276 : range_iterator<R>
277 {
278 };
279
280 template<class R, class P>
281 typename range_iterator<R>::type
282 execute(R& r, P p, mpl::true_) const
283 {
284 r.remove_if(p);
285 return detail::end_(r);
286 }
287
288 template<class R, class P>
289 typename range_iterator<R>::type
290 execute(R& r, P p, mpl::false_) const
291 {
292 return std::remove_if(detail::begin_(r), detail::end_(r), p);
293 }
294
295 template<class R, class P>
296 typename range_iterator<R>::type
297 operator()(R& r, P p) const
298 {
299 return execute(r, p, has_remove_if<R>());
300 }
301 };
302
303 struct remove_copy
304 {
305 template <typename Sig>
306 struct result;
307
308 template<typename This, class R, class O, class T>
309 struct result<This(R&, O, T)>
310 : detail::decay_array<O>
311 {};
312
313 template<class R, class O, class T>
314 typename detail::decay_array<O>::type
315 operator()(R& r, O o, T const& x) const
316 {
317 return std::remove_copy(detail::begin_(r), detail::end_(r), o, x);
318 }
319 };
320
321 struct remove_copy_if
322 {
323 template <typename Sig>
324 struct result;
325
326 template<typename This, class R, class O, class P>
327 struct result<This(R&, O, P)>
328 : detail::decay_array<O>
329 {};
330
331 template<class R, class O, class P>
332 typename detail::decay_array<O>::type
333 operator()(R& r, O o, P p) const
334 {
335 return std::remove_copy_if(detail::begin_(r), detail::end_(r), o, p);
336 }
337 };
338
339 struct unique
340 {
341 template <typename Sig>
342 struct result;
343
344 template<typename This, class R>
345 struct result<This(R&)>
346 : range_iterator<R>
347 {};
348
349 template<typename This, class R, class P>
350 struct result<This(R&, P)>
351 : range_iterator<R>
352 {};
353
354 template<class R>
355 typename range_iterator<R>::type
356 execute(R& r, mpl::true_) const
357 {
358 r.unique();
359 return detail::end_(r);
360 }
361
362 template<class R>
363 typename range_iterator<R>::type
364 execute(R& r, mpl::false_) const
365 {
366 return std::unique(detail::begin_(r), detail::end_(r));
367 }
368
369 template<class R>
370 typename range_iterator<R>::type
371 operator()(R& r) const
372 {
373 return execute(r, has_unique<R>());
374 }
375
376
377 template<class R, class P>
378 typename range_iterator<R>::type
379 execute(R& r, P p, mpl::true_) const
380 {
381 r.unique(p);
382 return detail::end_(r);
383 }
384
385 template<class R, class P>
386 typename range_iterator<R>::type
387 execute(R& r, P p, mpl::false_) const
388 {
389 return std::unique(detail::begin_(r), detail::end_(r), p);
390 }
391
392 template<class R, class P>
393 typename range_iterator<R>::type
394 operator()(R& r, P p) const
395 {
396 return execute(r, p, has_unique<R>());
397 }
398 };
399
400 struct unique_copy
401 {
402 template <typename Sig>
403 struct result;
404
405 template<typename This, class R, class O>
406 struct result<This(R&, O)>
407 : detail::decay_array<O>
408 {};
409
410 template<typename This, class R, class O, class P>
411 struct result<This(R&, O, P)>
412 : detail::decay_array<O>
413 {};
414
415 template<class R, class O>
416 typename detail::decay_array<O>::type operator()(R& r, O o) const
417 {
418 return std::unique_copy(
419 detail::begin_(r)
420 , detail::end_(r)
421 , o
422 );
423 }
424
425 template<class R, class O, class P>
426 typename detail::decay_array<O>::type operator()(R& r, O o, P p) const
427 {
428 return std::unique_copy(
429 detail::begin_(r)
430 , detail::end_(r)
431 , o
432 , p
433 );
434 }
435 };
436
437 struct reverse
438 {
439 typedef void result_type;
440
441 template<class R>
442 void execute(R& r, mpl::true_) const
443 {
444 r.reverse();
445 }
446
447 template<class R>
448 void execute(R& r, mpl::false_) const
449 {
450 std::reverse(detail::begin_(r), detail::end_(r));
451 }
452
453 template<class R>
454 void operator()(R& r) const
455 {
456 execute(r, has_reverse<R>());
457 }
458 };
459
460 struct reverse_copy
461 {
462 template <typename Sig>
463 struct result;
464
465 template<typename This, class R, class O>
466 struct result<This(R&, O)>
467 : detail::decay_array<O>
468 {};
469
470 template<class R, class O>
471 typename detail::decay_array<O>::type operator()(R& r, O o) const
472 {
473 return std::reverse_copy(
474 detail::begin_(r)
475 , detail::end_(r)
476 , o
477 );
478 }
479 };
480
481 struct rotate
482 {
483 typedef void result_type;
484
485 template<class R, class M>
486 void operator()(R& r, M m) const
487 {
488 std::rotate(
489 detail::begin_(r)
490 , m
491 , detail::end_(r)
492 );
493 }
494 };
495
496 struct rotate_copy
497 {
498 template <typename Sig>
499 struct result;
500
501 template<typename This, class R, class M, class O>
502 struct result<This(R&, M, O)>
503 : detail::decay_array<O>
504 {};
505
506 template<class R, class M, class O>
507 typename detail::decay_array<O>::type operator()(R& r, M m, O o) const
508 {
509 return std::rotate_copy(
510 detail::begin_(r)
511 , m
512 , detail::end_(r)
513 , o
514 );
515 }
516 };
517
518 struct random_shuffle
519 {
520 typedef void result_type;
521
522 template<class R>
523 void operator()(R& r) const
524 {
525 return std::random_shuffle(detail::begin_(r), detail::end_(r));
526 }
527
528 template<class R, class G>
529 void operator()(R& r, G g) const
530 {
531 return std::random_shuffle(detail::begin_(r), detail::end_(r), g);
532 }
533 };
534
535 struct partition
536 {
537 template <typename Sig>
538 struct result;
539
540 template <typename This, class R, class P>
541 struct result<This(R&, P)>
542 : range_iterator<R>
543 {};
544
545 template<class R, class P>
546 typename range_iterator<R>::type
547 operator()(R& r, P p) const
548 {
549 return std::partition(detail::begin_(r), detail::end_(r), p);
550 }
551 };
552
553 struct stable_partition
554 {
555 template <typename Sig>
556 struct result;
557
558 template <typename This, class R, class P>
559 struct result<This(R&, P)>
560 : range_iterator<R>
561 {};
562
563 template<class R, class P>
564 typename range_iterator<R>::type
565 operator()(R& r, P p) const
566 {
567 return std::stable_partition(detail::begin_(r), detail::end_(r), p);
568 }
569 };
570
571 struct sort
572 {
573 typedef void result_type;
574
575 template<class R>
576 void execute(R& r, mpl::true_) const
577 {
578 r.sort();
579 }
580
581 template<class R>
582 void execute(R& r, mpl::false_) const
583 {
584 std::sort(detail::begin_(r), detail::end_(r));
585 }
586
587 template<class R>
588 void operator()(R& r) const
589 {
590 execute(r, has_sort<R>());
591 }
592
593 template<class R, class C>
594 void execute(R& r, C c, mpl::true_) const
595 {
596 r.sort(c);
597 }
598
599 template<class R, class C>
600 void execute(R& r, C c, mpl::false_) const
601 {
602 std::sort(detail::begin_(r), detail::end_(r), c);
603 }
604
605 template<class R, class C>
606 void operator()(R& r, C c) const
607 {
608 execute(r, c, has_sort<R>());
609 }
610 };
611
612 struct stable_sort
613 {
614 typedef void result_type;
615
616 template<class R>
617 void operator()(R& r) const
618 {
619 std::stable_sort(detail::begin_(r), detail::end_(r));
620 }
621
622 template<class R, class C>
623 void operator()(R& r, C c) const
624 {
625 std::stable_sort(detail::begin_(r), detail::end_(r), c);
626 }
627 };
628
629 struct partial_sort
630 {
631 typedef void result_type;
632
633 template<class R, class M>
634 void operator()(R& r, M m) const
635 {
636 std::partial_sort(detail::begin_(r), m, detail::end_(r));
637 }
638
639 template<class R, class M, class C>
640 void operator()(R& r, M m, C c) const
641 {
642 std::partial_sort(detail::begin_(r), m, detail::end_(r), c);
643 }
644 };
645
646 struct partial_sort_copy
647 {
648 template <typename Sig>
649 struct result;
650
651 template <typename This, class R1, class R2>
652 struct result<This(R1&, R2&)>
653 : range_iterator<R2>
654 {};
655
656 template <typename This, class R1, class R2, class C>
657 struct result<This(R1&, R2&, C)>
658 : range_iterator<R2>
659 {};
660
661 template <class R1, class R2>
662 typename range_iterator<R2>::type
663 operator()(R1& r1, R2& r2) const
664 {
665 return std::partial_sort_copy(
666 detail::begin_(r1), detail::end_(r1)
667 , detail::begin_(r2), detail::end_(r2)
668 );
669 }
670
671 template <class R1, class R2, class C>
672 typename range_iterator<R2>::type
673 operator()(R1& r1, R2& r2, C c) const
674 {
675 return std::partial_sort_copy(
676 detail::begin_(r1), detail::end_(r1)
677 , detail::begin_(r2), detail::end_(r2)
678 , c
679 );
680 }
681 };
682
683 struct nth_element
684 {
685 typedef void result_type;
686
687 template<class R, class N>
688 void operator()(R& r, N n) const
689 {
690 return std::nth_element(detail::begin_(r), n, detail::end_(r));
691 }
692
693 template<class R, class N, class C>
694 void operator()(R& r, N n, C c) const
695 {
696 return std::nth_element(detail::begin_(r), n, detail::end_(r), c);
697 }
698 };
699
700 struct merge
701 {
702 template <typename Sig>
703 struct result;
704
705 template<typename This, class R1, class R2, class O>
706 struct result<This(R1&, R2&, O)>
707 : detail::decay_array<O>
708 {};
709
710 template<typename This, class R1, class R2, class O, class C>
711 struct result<This(R1&, R2&, O, C)>
712 : detail::decay_array<O>
713 {};
714
715 template<class R1, class R2, class O>
716 typename detail::decay_array<O>::type operator()(R1& r1, R2& r2, O o) const
717 {
718 return std::merge(
719 detail::begin_(r1), detail::end_(r1)
720 , detail::begin_(r2), detail::end_(r2)
721 , o
722 );
723 }
724
725 template<class R1, class R2, class O, class C>
726 typename detail::decay_array<O>::type operator()(R1& r1, R2& r2, O o, C c) const
727 {
728 return std::merge(
729 detail::begin_(r1), detail::end_(r1)
730 , detail::begin_(r2), detail::end_(r2)
731 , o
732 , c
733 );
734 }
735 };
736
737 struct inplace_merge
738 {
739 typedef void result_type;
740
741 template<class R, class M>
742 void operator()(R& r, M m) const
743 {
744 return std::inplace_merge(detail::begin_(r), m, detail::end_(r));
745 }
746
747 template<class R, class M, class C>
748 void operator()(R& r, M m, C c) const
749 {
750 return std::inplace_merge(detail::begin_(r), m, detail::end_(r), c);
751 }
752 };
753
754 struct next_permutation
755 {
756 typedef bool result_type;
757
758 template<class R>
759 bool operator()(R& r) const
760 {
761 return std::next_permutation(detail::begin_(r), detail::end_(r));
762 }
763
764 template<class R, class C>
765 bool operator()(R& r, C c) const
766 {
767 return std::next_permutation(detail::begin_(r), detail::end_(r), c);
768 }
769 };
770
771 struct prev_permutation
772 {
773 typedef bool result_type;
774
775 template<class R>
776 bool operator()(R& r) const
777 {
778 return std::prev_permutation(detail::begin_(r), detail::end_(r));
779 }
780
781 template<class R, class C>
782 bool operator()(R& r, C c) const
783 {
784 return std::prev_permutation(detail::begin_(r), detail::end_(r), c);
785 }
786 };
787
788
789 struct inner_product
790 {
791 template <typename Sig>
792 struct result;
793
794 template <typename This, typename R, typename I, typename T>
795 struct result<This(R&, I, T)>
796 : result<This(R&, I const &, T)>
797 {};
798
799 template <typename This, typename R, typename I, typename T>
800 struct result<This(R&, I, T &)>
801 {
802 typedef T type;
803 };
804
805 template <typename This, typename R, typename I, typename T, typename C1, typename C2>
806 struct result<This(R&, I, T, C1, C2)>
807 : result<This(R&, I, T const &, C1, C2)>
808 {};
809
810 template <typename This, typename R, typename I, typename T, typename C1, typename C2>
811 struct result<This(R&, I, T &, C1, C2)>
812 {
813 typedef T type;
814 };
815
816 template <class R, class I, class T>
817 T
818 operator()(R& r, I i, T t) const
819 {
820 return std::inner_product(
821 detail::begin_(r), detail::end_(r), i, t);
822 }
823
824 template <class R, class I, class T, class C1, class C2>
825 T
826 operator()(R& r, I i, T t, C1 c1, C2 c2) const
827 {
828 return std::inner_product(
829 detail::begin_(r), detail::end_(r), i,
830 t, c1, c2);
831 }
832 };
833
834 struct partial_sum
835 {
836 template <typename Sig>
837 struct result;
838
839 template <typename This, class R, class I>
840 struct result<This(R&, I)>
841 : detail::decay_array<I>
842 {};
843
844 template <typename This, class R, class I, class C>
845 struct result<This(R&, I, C)>
846 : detail::decay_array<I>
847 {};
848
849 template <class R, class I>
850 typename detail::decay_array<I>::type
851 operator()(R& r, I i) const
852 {
853 return std::partial_sum(
854 detail::begin_(r), detail::end_(r), i);
855 }
856
857 template <class R, class I, class C>
858 typename detail::decay_array<I>::type
859 operator()(R& r, I i, C c) const
860 {
861 return std::partial_sum(
862 detail::begin_(r), detail::end_(r), i, c);
863 }
864 };
865
866 struct adjacent_difference
867 {
868 template <typename Sig>
869 struct result;
870
871 template <typename This, class R, class I>
872 struct result<This(R&, I)>
873 : detail::decay_array<I>
874 {};
875
876 template <typename This,class R, class I, class C>
877 struct result<This(R&, I, C)>
878 : detail::decay_array<I>
879 {};
880
881 template <class R, class I>
882 typename detail::decay_array<I>::type
883 operator()(R& r, I i) const
884 {
885 return std::adjacent_difference(
886 detail::begin_(r), detail::end_(r), i);
887 }
888
889 template <class R, class I, class C>
890 typename detail::decay_array<I>::type
891 operator()(R& r, I i, C c) const
892 {
893 return std::adjacent_difference(
894 detail::begin_(r), detail::end_(r), i, c);
895 }
896 };
897
898 struct push_heap
899 {
900 typedef void result_type;
901
902 template <class R>
903 void operator()(R& r) const
904 {
905 std::push_heap(detail::begin_(r), detail::end_(r));
906 }
907
908 template <class R, class C>
909 void operator()(R& r, C c) const
910 {
911 std::push_heap(detail::begin_(r), detail::end_(r), c);
912 }
913 };
914
915 struct pop_heap
916 {
917 typedef void result_type;
918
919 template <class R>
920 void operator()(R& r) const
921 {
922 std::pop_heap(detail::begin_(r), detail::end_(r));
923 }
924
925 template <class R, class C>
926 void operator()(R& r, C c) const
927 {
928 std::pop_heap(detail::begin_(r), detail::end_(r), c);
929 }
930 };
931
932 struct make_heap
933 {
934 typedef void result_type;
935
936 template <class R>
937 void operator()(R& r) const
938 {
939 std::make_heap(detail::begin_(r), detail::end_(r));
940 }
941
942 template <class R, class C>
943 void operator()(R& r, C c) const
944 {
945 std::make_heap(detail::begin_(r), detail::end_(r), c);
946 }
947 };
948
949 struct sort_heap
950 {
951 typedef void result_type;
952
953 template <class R>
954 void operator()(R& r) const
955 {
956 std::sort_heap(detail::begin_(r), detail::end_(r));
957 }
958
959 template <class R, class C>
960 void operator()(R& r, C c) const
961 {
962 std::sort_heap(detail::begin_(r), detail::end_(r), c);
963 }
964 };
965
966 struct set_union
967 {
968 template <typename Sig>
969 struct result;
970
971 template <typename This, class R1, class R2, class O>
972 struct result<This(R1&, R2&, O)>
973 : detail::decay_array<O>
974 {};
975
976 template <typename This, class R1, class R2, class O, typename C>
977 struct result<This(R1&, R2&, O, C)>
978 : detail::decay_array<O>
979 {};
980
981 template <class R1, class R2, class O>
982 typename detail::decay_array<O>::type
983 operator()(R1& r1, R2& r2, O o) const
984 {
985 return std::set_union(
986 detail::begin_(r1), detail::end_(r1)
987 , detail::begin_(r2), detail::end_(r2)
988 , o
989 );
990 }
991
992 template <class R1, class R2, class O, class C>
993 typename detail::decay_array<O>::type
994 operator()(R1& r1, R2& r2, O o, C c) const
995 {
996 return std::set_union(
997 detail::begin_(r1), detail::end_(r1)
998 , detail::begin_(r2), detail::end_(r2)
999 , o
1000 , c
1001 );
1002 }
1003 };
1004
1005 struct set_intersection
1006 {
1007 template <typename Sig>
1008 struct result;
1009
1010 template <typename This, class R1, class R2, class O>
1011 struct result<This(R1&, R2&, O)>
1012 : detail::decay_array<O>
1013 {};
1014
1015 template <typename This, class R1, class R2, class O, typename C>
1016 struct result<This(R1&, R2&, O, C)>
1017 : detail::decay_array<O>
1018 {};
1019
1020 template <class R1, class R2, class O>
1021 typename detail::decay_array<O>::type
1022 operator()(R1& r1, R2& r2, O o) const
1023 {
1024 return std::set_intersection(
1025 detail::begin_(r1), detail::end_(r1)
1026 , detail::begin_(r2), detail::end_(r2)
1027 , o
1028 );
1029 }
1030
1031 template <class R1, class R2, class O, class C>
1032 typename detail::decay_array<O>::type
1033 operator()(R1& r1, R2& r2, O o, C c) const
1034 {
1035 return std::set_intersection(
1036 detail::begin_(r1), detail::end_(r1)
1037 , detail::begin_(r2), detail::end_(r2)
1038 , o
1039 , c
1040 );
1041 }
1042 };
1043
1044 struct set_difference
1045 {
1046 template <typename Sig>
1047 struct result;
1048
1049 template <typename This, class R1, class R2, class O>
1050 struct result<This(R1&, R2&, O)>
1051 : detail::decay_array<O>
1052 {};
1053
1054 template <typename This, class R1, class R2, class O, class C>
1055 struct result<This(R1&, R2&, O, C)>
1056 : detail::decay_array<O>
1057 {};
1058
1059 template <class R1, class R2, class O>
1060 typename detail::decay_array<O>::type
1061 operator()(R1& r1, R2& r2, O o) const
1062 {
1063 return std::set_difference(
1064 detail::begin_(r1), detail::end_(r1)
1065 , detail::begin_(r2), detail::end_(r2)
1066 , o
1067 );
1068 }
1069
1070 template <class R1, class R2, class O, class C>
1071 typename detail::decay_array<O>::type
1072 operator()(R1& r1, R2& r2, O o, C c) const
1073 {
1074 return std::set_difference(
1075 detail::begin_(r1), detail::end_(r1)
1076 , detail::begin_(r2), detail::end_(r2)
1077 , o
1078 , c
1079 );
1080 }
1081 };
1082
1083 struct set_symmetric_difference
1084 {
1085 template <typename Sig>
1086 struct result;
1087
1088 template <typename This, class R1, class R2, class O>
1089 struct result<This(R1&, R2, O)>
1090 : detail::decay_array<O>
1091 {};
1092
1093 template <typename This, class R1, class R2, class O, class C>
1094 struct result<This(R1&, R2, O, C)>
1095 : detail::decay_array<O>
1096 {};
1097
1098 template <class R1, class R2, class O>
1099 typename detail::decay_array<O>::type
1100 operator()(R1& r1, R2& r2, O o) const
1101 {
1102 return std::set_symmetric_difference(
1103 detail::begin_(r1), detail::end_(r1)
1104 , detail::begin_(r2), detail::end_(r2)
1105 , o
1106 );
1107 }
1108
1109 template <class R1, class R2, class O, class C>
1110 typename detail::decay_array<O>::type
1111 operator()(R1& r1, R2& r2, O o, C c) const
1112 {
1113 return std::set_symmetric_difference(
1114 detail::begin_(r1), detail::end_(r1)
1115 , detail::begin_(r2), detail::end_(r2)
1116 , o
1117 , c
1118 );
1119 }
1120 };
1121
1122 }}} // boost::phoenix::impl
1123
1124 namespace boost { namespace phoenix
1125 {
1126 BOOST_PHOENIX_ADAPT_CALLABLE(swap, impl::swap, 2)
1127 BOOST_PHOENIX_ADAPT_CALLABLE(copy, impl::copy, 2)
1128 BOOST_PHOENIX_ADAPT_CALLABLE(copy_backward, impl::copy_backward, 2)
1129 BOOST_PHOENIX_ADAPT_CALLABLE(transform, impl::transform, 3)
1130 BOOST_PHOENIX_ADAPT_CALLABLE(transform, impl::transform, 4)
1131 BOOST_PHOENIX_ADAPT_CALLABLE(replace, impl::replace, 3)
1132 BOOST_PHOENIX_ADAPT_CALLABLE(replace_if, impl::replace_if, 3)
1133 BOOST_PHOENIX_ADAPT_CALLABLE(replace_copy, impl::replace_copy, 4)
1134 BOOST_PHOENIX_ADAPT_CALLABLE(replace_copy_if, impl::replace_copy_if, 4)
1135 BOOST_PHOENIX_ADAPT_CALLABLE(fill, impl::fill, 2)
1136 BOOST_PHOENIX_ADAPT_CALLABLE(fill_n, impl::fill_n, 3)
1137 BOOST_PHOENIX_ADAPT_CALLABLE(generate, impl::generate, 2)
1138 BOOST_PHOENIX_ADAPT_CALLABLE(generate_n, impl::generate_n, 3)
1139 BOOST_PHOENIX_ADAPT_CALLABLE(remove, impl::remove, 2)
1140 BOOST_PHOENIX_ADAPT_CALLABLE(remove_if, impl::remove_if, 2)
1141 BOOST_PHOENIX_ADAPT_CALLABLE(remove_copy, impl::remove_copy, 3)
1142 BOOST_PHOENIX_ADAPT_CALLABLE(remove_copy_if, impl::remove_copy_if, 3)
1143 BOOST_PHOENIX_ADAPT_CALLABLE(unique, impl::unique, 1)
1144 BOOST_PHOENIX_ADAPT_CALLABLE(unique, impl::unique, 2)
1145 BOOST_PHOENIX_ADAPT_CALLABLE(unique_copy, impl::unique_copy, 2)
1146 BOOST_PHOENIX_ADAPT_CALLABLE(unique_copy, impl::unique_copy, 3)
1147 BOOST_PHOENIX_ADAPT_CALLABLE(reverse, impl::reverse, 1)
1148 BOOST_PHOENIX_ADAPT_CALLABLE(reverse_copy, impl::reverse_copy, 2)
1149 BOOST_PHOENIX_ADAPT_CALLABLE(rotate, impl::rotate, 2)
1150 BOOST_PHOENIX_ADAPT_CALLABLE(rotate_copy, impl::rotate_copy, 3)
1151 BOOST_PHOENIX_ADAPT_CALLABLE(random_shuffle, impl::random_shuffle, 1)
1152 BOOST_PHOENIX_ADAPT_CALLABLE(random_shuffle, impl::random_shuffle, 2)
1153 BOOST_PHOENIX_ADAPT_CALLABLE(partition, impl::partition, 2)
1154 BOOST_PHOENIX_ADAPT_CALLABLE(stable_partition, impl::stable_partition, 2)
1155 BOOST_PHOENIX_ADAPT_CALLABLE(sort, impl::sort, 1)
1156 BOOST_PHOENIX_ADAPT_CALLABLE(sort, impl::sort, 2)
1157 BOOST_PHOENIX_ADAPT_CALLABLE(stable_sort, impl::stable_sort, 1)
1158 BOOST_PHOENIX_ADAPT_CALLABLE(stable_sort, impl::stable_sort, 2)
1159 BOOST_PHOENIX_ADAPT_CALLABLE(partial_sort, impl::partial_sort, 2)
1160 BOOST_PHOENIX_ADAPT_CALLABLE(partial_sort, impl::partial_sort, 3)
1161 BOOST_PHOENIX_ADAPT_CALLABLE(partial_sort_copy, impl::partial_sort_copy, 2)
1162 BOOST_PHOENIX_ADAPT_CALLABLE(partial_sort_copy, impl::partial_sort_copy, 3)
1163 BOOST_PHOENIX_ADAPT_CALLABLE(nth_element, impl::nth_element, 2)
1164 BOOST_PHOENIX_ADAPT_CALLABLE(nth_element, impl::nth_element, 3)
1165 BOOST_PHOENIX_ADAPT_CALLABLE(merge, impl::merge, 3)
1166 BOOST_PHOENIX_ADAPT_CALLABLE(merge, impl::merge, 4)
1167 BOOST_PHOENIX_ADAPT_CALLABLE(inplace_merge, impl::inplace_merge, 2)
1168 BOOST_PHOENIX_ADAPT_CALLABLE(inplace_merge, impl::inplace_merge, 3)
1169 BOOST_PHOENIX_ADAPT_CALLABLE(next_permutation, impl::next_permutation, 1)
1170 BOOST_PHOENIX_ADAPT_CALLABLE(next_permutation, impl::next_permutation, 2)
1171 BOOST_PHOENIX_ADAPT_CALLABLE(prev_permutation, impl::prev_permutation, 1)
1172 BOOST_PHOENIX_ADAPT_CALLABLE(prev_permutation, impl::prev_permutation, 2)
1173 BOOST_PHOENIX_ADAPT_CALLABLE(inner_product, impl::inner_product, 3)
1174 BOOST_PHOENIX_ADAPT_CALLABLE(inner_product, impl::inner_product, 5)
1175 BOOST_PHOENIX_ADAPT_CALLABLE(partial_sum, impl::partial_sum, 2)
1176 BOOST_PHOENIX_ADAPT_CALLABLE(partial_sum, impl::partial_sum, 3)
1177 BOOST_PHOENIX_ADAPT_CALLABLE(adjacent_difference, impl::adjacent_difference, 2)
1178 BOOST_PHOENIX_ADAPT_CALLABLE(adjacent_difference, impl::adjacent_difference, 3)
1179 BOOST_PHOENIX_ADAPT_CALLABLE(push_heap, impl::push_heap, 1)
1180 BOOST_PHOENIX_ADAPT_CALLABLE(push_heap, impl::push_heap, 2)
1181 BOOST_PHOENIX_ADAPT_CALLABLE(pop_heap, impl::pop_heap, 1)
1182 BOOST_PHOENIX_ADAPT_CALLABLE(pop_heap, impl::pop_heap, 2)
1183 BOOST_PHOENIX_ADAPT_CALLABLE(make_heap, impl::make_heap, 1)
1184 BOOST_PHOENIX_ADAPT_CALLABLE(make_heap, impl::make_heap, 2)
1185 BOOST_PHOENIX_ADAPT_CALLABLE(sort_heap, impl::sort_heap, 1)
1186 BOOST_PHOENIX_ADAPT_CALLABLE(sort_heap, impl::sort_heap, 2)
1187 BOOST_PHOENIX_ADAPT_CALLABLE(set_union, impl::set_union, 3)
1188 BOOST_PHOENIX_ADAPT_CALLABLE(set_union, impl::set_union, 4)
1189 BOOST_PHOENIX_ADAPT_CALLABLE(set_intersection, impl::set_intersection, 3)
1190 BOOST_PHOENIX_ADAPT_CALLABLE(set_intersection, impl::set_intersection, 4)
1191 BOOST_PHOENIX_ADAPT_CALLABLE(set_difference, impl::set_difference, 3)
1192 BOOST_PHOENIX_ADAPT_CALLABLE(set_difference, impl::set_difference, 4)
1193 BOOST_PHOENIX_ADAPT_CALLABLE(set_symmetric_difference, impl::set_symmetric_difference, 3)
1194 BOOST_PHOENIX_ADAPT_CALLABLE(set_symmetric_difference, impl::set_symmetric_difference, 4)
1195 }}
1196
1197 #endif