Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:47:41

0001 // Copyright 2005 Daniel Wallin.
0002 // Copyright 2005 Joel de Guzman.
0003 // Copyright 2005 Dan Marsden.
0004 // Copyright 2015 John Fletcher.
0005 //
0006 // Use, modification and distribution is subject to the Boost Software
0007 // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
0008 // http://www.boost.org/LICENSE_1_0.txt)
0009 //
0010 // Modeled after range_ex, Copyright 2004 Eric Niebler
0011 
0012 #ifndef BOOST_PHOENIX_ALGORITHM_TRANSFORMATION_HPP
0013 #define BOOST_PHOENIX_ALGORITHM_TRANSFORMATION_HPP
0014 
0015 #include <algorithm>
0016 #include <numeric>
0017 
0018 #include <boost/phoenix/core/limits.hpp>
0019 #include <boost/phoenix/stl/algorithm/detail/has_sort.hpp>
0020 #include <boost/phoenix/stl/algorithm/detail/has_remove.hpp>
0021 #include <boost/phoenix/stl/algorithm/detail/has_remove_if.hpp>
0022 #include <boost/phoenix/stl/algorithm/detail/has_unique.hpp>
0023 #include <boost/phoenix/stl/algorithm/detail/has_reverse.hpp>
0024 #include <boost/phoenix/stl/algorithm/detail/has_sort.hpp>
0025 
0026 #include <boost/phoenix/stl/algorithm/detail/begin.hpp>
0027 #include <boost/phoenix/stl/algorithm/detail/end.hpp>
0028 #include <boost/phoenix/stl/algorithm/detail/decay_array.hpp>
0029 
0030 #include <boost/phoenix/function/adapt_callable.hpp>
0031 
0032 //#include <boost/range/result_iterator.hpp> is deprecated
0033 #include <boost/range/iterator.hpp>
0034 #include <boost/range/difference_type.hpp>
0035 
0036 #include <boost/mpl/if.hpp>
0037 
0038 #include <boost/type_traits/is_void.hpp>
0039 
0040 namespace boost { namespace phoenix { namespace impl
0041 {
0042     struct swap
0043     {
0044         typedef void result_type;
0045 
0046         template <class A, class B>
0047         void operator()(A& a, B& b) const
0048         {
0049             using std::swap;
0050             swap(a, b);
0051         }
0052     };
0053 
0054     struct copy
0055     {
0056         template <typename Sig>
0057         struct result;
0058 
0059         template<typename This, class R, class I>
0060         struct result<This(R&, I)>
0061             : detail::decay_array<I>
0062         {};
0063 
0064         template<class R, class I>
0065         typename detail::decay_array<I>::type
0066         operator()(R& r, I i) const
0067         {
0068             return std::copy(detail::begin_(r), detail::end_(r), i);
0069         }
0070     };
0071 
0072     struct copy_backward
0073     {
0074         template <typename Sig>
0075         struct result;
0076 
0077         template<typename This, class R, class I>
0078         struct result<This(R&, I)>
0079             : result<This(R&, I const &)>
0080         {};
0081 
0082         template<typename This, class R, class I>
0083         struct result<This(R&, I &)>
0084         {
0085             typedef I type;
0086         };
0087 
0088         template<class R, class I>
0089         I operator()(R& r, I & i) const
0090         {
0091             return std::copy_backward(detail::begin_(r), detail::end_(r), i);
0092         }
0093 
0094         template<class R, class I>
0095         I const operator()(R& r, I const & i) const
0096         {
0097             return std::copy_backward(detail::begin_(r), detail::end_(r), i);
0098         }
0099     };
0100 
0101     struct transform
0102     {
0103         template <typename Sig>
0104         struct result;
0105         
0106         template<typename This, class R, class OutorI1, class ForOut>
0107         struct result<This(R&, OutorI1, ForOut)>
0108             : detail::decay_array<OutorI1>
0109         {
0110         };
0111 
0112         template<typename This, class R, class OutorI1, class ForOut, class BinF>
0113         struct result<This(R&, OutorI1, ForOut, BinF)>
0114             : detail::decay_array<ForOut>
0115         {
0116         };
0117 
0118         template<class R, class O, class F>
0119         typename result<transform(R&,O,F)>::type
0120         operator()(R& r, O o, F f) const
0121         {
0122             return std::transform(detail::begin_(r), detail::end_(r), o, f);
0123         }
0124 
0125         template<class R, class I, class O, class F>
0126         typename result<transform(R&,I,O,F)>::type
0127         operator()(R& r, I i, O o, F f) const
0128         {
0129             return std::transform(detail::begin_(r), detail::end_(r), i, o, f);
0130         }
0131     };
0132 
0133     struct replace
0134     {
0135         typedef void result_type;
0136 
0137         template<class R, class T>
0138         void operator()(R& r, T const& what, T const& with) const
0139         {
0140             std::replace(detail::begin_(r), detail::end_(r), what, with);
0141         }
0142     };
0143 
0144     struct replace_if
0145     {
0146         typedef void result_type;
0147 
0148         template<class R, class P, class T>
0149         void operator()(R& r, P p, T const& with) const
0150         {
0151             std::replace_if(detail::begin_(r), detail::end_(r), p, with);
0152         }
0153     };
0154 
0155     struct replace_copy
0156     {
0157         template <typename Sig>
0158         struct result;
0159 
0160         template<typename This, class R, class O, class T, class T2>
0161         struct result<This(R&, O, T&, T2&)>
0162             : detail::decay_array<O>
0163         {};
0164 
0165         template<class R, class O, class T>
0166         typename detail::decay_array<O>::type 
0167         operator()(R& r, O o, T const& what, T const& with) const
0168         {
0169             return std::replace_copy(detail::begin_(r), detail::end_(r), o, what, with);
0170         }
0171     };
0172 
0173     struct replace_copy_if
0174     {
0175         template <typename Sig>
0176         struct result;
0177 
0178         template<typename This, class R, class O, class P, class T>
0179         struct result<This(R&, O, P, T&)>
0180             : detail::decay_array<O>
0181         {};
0182 
0183         template<class R, class O, class P, class T>
0184         typename detail::decay_array<O>::type
0185         operator()(R& r, O o, P p, T const& with) const
0186         {
0187             return std::replace_copy_if(detail::begin_(r), detail::end_(r), o, p, with);
0188         }
0189     };
0190 
0191     struct fill
0192     {
0193         typedef void result_type;
0194 
0195         template<class R, class T>
0196         void operator()(R& r, T const& x) const
0197         {
0198             std::fill(detail::begin_(r), detail::end_(r), x);
0199         }
0200     };
0201 
0202     struct fill_n
0203     {
0204         typedef void result_type;
0205 
0206         template<class R, class N, class T>
0207         void operator()(R& r, N n, T const& x) const
0208         {
0209             std::fill_n(detail::begin_(r), n, x);
0210         }
0211     };
0212 
0213     struct generate
0214     {
0215         typedef void result_type;
0216 
0217         template<class R, class G>
0218         void operator()(R& r, G const & g) const
0219         {
0220             std::generate(detail::begin_(r), detail::end_(r), g);
0221         }
0222     };
0223 
0224     struct generate_n
0225     {
0226         typedef void result_type;
0227 
0228         template<class R, class N, class G>
0229         void operator()(R& r, N n, G g) const
0230         {
0231             std::generate_n(detail::begin_(r), n, g);
0232         }
0233     };
0234 
0235     struct remove
0236     {
0237         template <typename Sig>
0238         struct result;
0239 
0240         template<typename This, class R, class T>
0241         struct result<This(R&, T&)>
0242             : range_iterator<R>
0243         {
0244         };
0245 
0246         template<class R, class T>
0247         typename range_iterator<R>::type
0248         execute(R& r, T const& x, mpl::true_) const
0249         {
0250             r.remove(x);
0251             return detail::end_(r);
0252         }
0253 
0254         template<class R, class T>
0255         typename range_iterator<R>::type
0256         execute(R& r, T const& x, mpl::false_) const
0257         {
0258             return std::remove(detail::begin_(r), detail::end_(r), x);
0259         }
0260 
0261         template<class R, class T>
0262         typename range_iterator<R>::type
0263         operator()(R& r, T const& x) const
0264         {
0265             return execute(r, x, has_remove<R>());
0266         }
0267     };
0268 
0269     struct remove_if
0270     {
0271         template <typename Sig>
0272         struct result;
0273 
0274         template <typename This, class R, class P>
0275         struct result<This(R&,P)>
0276             : range_iterator<R>
0277         {
0278         };
0279 
0280         template<class R, class P>
0281         typename range_iterator<R>::type
0282         execute(R& r, P p, mpl::true_) const
0283         {
0284             r.remove_if(p);
0285             return detail::end_(r);
0286         }
0287 
0288         template<class R, class P>
0289         typename range_iterator<R>::type
0290         execute(R& r, P p, mpl::false_) const
0291         {
0292             return std::remove_if(detail::begin_(r), detail::end_(r), p);
0293         }
0294 
0295         template<class R, class P>
0296         typename range_iterator<R>::type
0297         operator()(R& r, P p) const
0298         {
0299             return execute(r, p, has_remove_if<R>());
0300         }
0301     };
0302 
0303     struct remove_copy
0304     {
0305         template <typename Sig>
0306         struct result;
0307 
0308         template<typename This, class R, class O, class T>
0309         struct result<This(R&, O, T)>
0310             : detail::decay_array<O>
0311         {};
0312 
0313         template<class R, class O, class T>
0314         typename detail::decay_array<O>::type
0315         operator()(R& r, O o, T const& x) const
0316         {
0317             return std::remove_copy(detail::begin_(r), detail::end_(r), o, x);
0318         }
0319     };
0320 
0321     struct remove_copy_if
0322     {
0323         template <typename Sig>
0324         struct result;
0325 
0326         template<typename This, class R, class O, class P>
0327         struct result<This(R&, O, P)>
0328             : detail::decay_array<O>
0329         {};
0330 
0331         template<class R, class O, class P>
0332         typename detail::decay_array<O>::type
0333         operator()(R& r, O o, P p) const
0334         {
0335             return std::remove_copy_if(detail::begin_(r), detail::end_(r), o, p);
0336         }
0337     };
0338 
0339     struct unique
0340     {
0341         template <typename Sig>
0342         struct result;
0343 
0344         template<typename This, class R>
0345         struct result<This(R&)>
0346             : range_iterator<R>
0347         {};
0348 
0349         template<typename This, class R, class P>
0350         struct result<This(R&, P)>
0351             : range_iterator<R>
0352         {};
0353 
0354         template<class R>
0355         typename range_iterator<R>::type
0356         execute(R& r, mpl::true_) const
0357         {
0358             r.unique();
0359             return detail::end_(r);
0360         }
0361 
0362         template<class R>
0363         typename range_iterator<R>::type
0364         execute(R& r, mpl::false_) const
0365         {
0366             return std::unique(detail::begin_(r), detail::end_(r));
0367         }
0368 
0369         template<class R>
0370         typename range_iterator<R>::type
0371         operator()(R& r) const
0372         {
0373             return execute(r, has_unique<R>());
0374         }
0375 
0376 
0377         template<class R, class P>
0378         typename range_iterator<R>::type
0379         execute(R& r, P p, mpl::true_) const
0380         {
0381             r.unique(p);
0382             return detail::end_(r);
0383         }
0384 
0385         template<class R, class P>
0386         typename range_iterator<R>::type
0387         execute(R& r, P p, mpl::false_) const
0388         {
0389             return std::unique(detail::begin_(r), detail::end_(r), p);
0390         }
0391 
0392         template<class R, class P>
0393         typename range_iterator<R>::type
0394         operator()(R& r, P p) const
0395         {
0396             return execute(r, p, has_unique<R>());
0397         }
0398     };
0399 
0400     struct unique_copy
0401     {
0402         template <typename Sig>
0403         struct result;
0404 
0405         template<typename This, class R, class O>
0406         struct result<This(R&, O)>
0407             : detail::decay_array<O>
0408         {};
0409 
0410         template<typename This, class R, class O, class P>
0411         struct result<This(R&, O, P)>
0412             : detail::decay_array<O>
0413         {};
0414 
0415         template<class R, class O>
0416         typename detail::decay_array<O>::type operator()(R& r, O o) const
0417         {
0418             return std::unique_copy(
0419                 detail::begin_(r)
0420                 , detail::end_(r)
0421                 , o
0422                 );
0423         }
0424 
0425         template<class R, class O, class P>
0426         typename detail::decay_array<O>::type operator()(R& r, O o, P p) const
0427         {
0428             return std::unique_copy(
0429                 detail::begin_(r)
0430                 , detail::end_(r)
0431                 , o
0432                 , p
0433                 );
0434         }
0435     };
0436 
0437     struct reverse
0438     {
0439         typedef void result_type;
0440 
0441         template<class R>
0442         void execute(R& r, mpl::true_) const
0443         {
0444             r.reverse();
0445         }
0446 
0447         template<class R>
0448         void execute(R& r, mpl::false_) const
0449         {
0450             std::reverse(detail::begin_(r), detail::end_(r));
0451         }
0452 
0453         template<class R>
0454         void operator()(R& r) const
0455         {
0456             execute(r, has_reverse<R>());
0457         }
0458     };
0459 
0460     struct reverse_copy
0461     {
0462         template <typename Sig>
0463         struct result;
0464 
0465         template<typename This, class R, class O>
0466         struct result<This(R&, O)>
0467             : detail::decay_array<O>
0468         {};
0469 
0470         template<class R, class O>
0471         typename detail::decay_array<O>::type operator()(R& r, O o) const
0472         {
0473             return std::reverse_copy(
0474                 detail::begin_(r)
0475                 , detail::end_(r)
0476                 , o
0477                 );
0478         }
0479     };
0480 
0481     struct rotate
0482     {
0483         typedef void result_type;
0484 
0485         template<class R, class M>
0486         void operator()(R& r, M m) const
0487         {
0488             std::rotate(
0489                 detail::begin_(r)
0490                 , m
0491                 , detail::end_(r)
0492                 );
0493         }
0494     };
0495 
0496     struct rotate_copy
0497     {
0498         template <typename Sig>
0499         struct result;
0500 
0501         template<typename This, class R, class M, class O>
0502         struct result<This(R&, M, O)>
0503             : detail::decay_array<O>
0504         {};
0505 
0506         template<class R, class M, class O>
0507         typename detail::decay_array<O>::type operator()(R& r, M m, O o) const
0508         {
0509             return std::rotate_copy(
0510                 detail::begin_(r)
0511                 , m
0512                 , detail::end_(r)
0513                 , o
0514                 );
0515         }
0516     };
0517 
0518 #ifndef BOOST_NO_CXX98_RANDOM_SHUFFLE
0519     struct random_shuffle
0520     {
0521         typedef void result_type;
0522 
0523         template<class R>
0524         void operator()(R& r) const
0525         {
0526             return std::random_shuffle(detail::begin_(r), detail::end_(r));
0527         }
0528 
0529         template<class R, class G>
0530         void operator()(R& r, G g) const
0531         {
0532             return std::random_shuffle(detail::begin_(r), detail::end_(r), g);
0533         }
0534     };
0535 #endif
0536 
0537     struct partition
0538     {
0539         template <typename Sig>
0540         struct result;
0541 
0542         template <typename This, class R, class P>
0543         struct result<This(R&, P)>
0544             : range_iterator<R>
0545         {};
0546 
0547         template<class R, class P>
0548         typename range_iterator<R>::type
0549         operator()(R& r, P p) const
0550         {
0551             return std::partition(detail::begin_(r), detail::end_(r), p);
0552         }
0553     };
0554 
0555     struct stable_partition
0556     {
0557         template <typename Sig>
0558         struct result;
0559 
0560         template <typename This, class R, class P>
0561         struct result<This(R&, P)>
0562             : range_iterator<R>
0563         {};
0564 
0565         template<class R, class P>
0566         typename range_iterator<R>::type
0567         operator()(R& r, P p) const
0568         {
0569             return std::stable_partition(detail::begin_(r), detail::end_(r), p);
0570         }
0571     };
0572 
0573     struct sort
0574     {
0575         typedef void result_type;
0576 
0577         template<class R>
0578         void execute(R& r, mpl::true_) const
0579         {
0580             r.sort();
0581         }
0582 
0583         template<class R>
0584         void execute(R& r, mpl::false_) const
0585         {
0586             std::sort(detail::begin_(r), detail::end_(r));
0587         }
0588 
0589         template<class R>
0590         void operator()(R& r) const
0591         {
0592             execute(r, has_sort<R>());
0593         }
0594 
0595         template<class R, class C>
0596         void execute(R& r, C c, mpl::true_) const
0597         {
0598             r.sort(c);
0599         }
0600 
0601         template<class R, class C>
0602         void execute(R& r, C c, mpl::false_) const
0603         {
0604             std::sort(detail::begin_(r), detail::end_(r), c);
0605         }
0606 
0607         template<class R, class C>
0608         void operator()(R& r, C c) const
0609         {
0610             execute(r, c, has_sort<R>());
0611         }
0612     };
0613 
0614     struct stable_sort
0615     {
0616         typedef void result_type;
0617 
0618         template<class R>
0619         void operator()(R& r) const
0620         {
0621             std::stable_sort(detail::begin_(r), detail::end_(r));
0622         }
0623 
0624         template<class R, class C>
0625         void operator()(R& r, C c) const
0626         {
0627             std::stable_sort(detail::begin_(r), detail::end_(r), c);
0628         }
0629     };
0630 
0631     struct partial_sort
0632     {
0633         typedef void result_type;
0634 
0635         template<class R, class M>
0636         void operator()(R& r, M m) const
0637         {
0638             std::partial_sort(detail::begin_(r), m, detail::end_(r));
0639         }
0640 
0641         template<class R, class M, class C>
0642         void operator()(R& r, M m, C c) const
0643         {
0644             std::partial_sort(detail::begin_(r), m, detail::end_(r), c);
0645         }
0646     };
0647 
0648     struct partial_sort_copy
0649     {
0650         template <typename Sig>
0651         struct result;
0652         
0653         template <typename This, class R1, class R2>
0654         struct result<This(R1&, R2&)>
0655             : range_iterator<R2>
0656         {};
0657 
0658         template <typename This, class R1, class R2, class C>
0659         struct result<This(R1&, R2&, C)>
0660             : range_iterator<R2>
0661         {};
0662 
0663         template <class R1, class R2>
0664         typename range_iterator<R2>::type
0665         operator()(R1& r1, R2& r2) const
0666         {
0667             return std::partial_sort_copy(
0668                 detail::begin_(r1), detail::end_(r1)
0669                 , detail::begin_(r2), detail::end_(r2)
0670                 );
0671         }
0672 
0673         template <class R1, class R2, class C>
0674         typename range_iterator<R2>::type
0675         operator()(R1& r1, R2& r2, C c) const
0676         {
0677             return std::partial_sort_copy(
0678                 detail::begin_(r1), detail::end_(r1)
0679                 , detail::begin_(r2), detail::end_(r2)
0680                 , c
0681                 );
0682         }
0683     };
0684 
0685     struct nth_element
0686     {
0687         typedef void result_type;
0688 
0689         template<class R, class N>
0690         void operator()(R& r, N n) const
0691         {
0692             return std::nth_element(detail::begin_(r), n, detail::end_(r));
0693         }
0694 
0695         template<class R, class N, class C>
0696         void operator()(R& r, N n, C c) const
0697         {
0698             return std::nth_element(detail::begin_(r), n, detail::end_(r), c);
0699         }
0700     };
0701 
0702     struct merge 
0703     {
0704         template <typename Sig>
0705         struct result;
0706 
0707         template<typename This, class R1, class R2, class O>
0708         struct result<This(R1&, R2&, O)>
0709             : detail::decay_array<O>
0710         {};
0711 
0712         template<typename This, class R1, class R2, class O, class C>
0713         struct result<This(R1&, R2&, O, C)>
0714             : detail::decay_array<O>
0715         {};
0716 
0717         template<class R1, class R2, class O>
0718         typename detail::decay_array<O>::type operator()(R1& r1, R2& r2, O o) const
0719         {
0720             return std::merge(
0721                 detail::begin_(r1), detail::end_(r1)
0722                 , detail::begin_(r2), detail::end_(r2)
0723                 , o
0724                 );
0725         }
0726 
0727         template<class R1, class R2, class O, class C>
0728         typename detail::decay_array<O>::type operator()(R1& r1, R2& r2, O o, C c) const
0729         {
0730             return std::merge(
0731                 detail::begin_(r1), detail::end_(r1)
0732                 , detail::begin_(r2), detail::end_(r2)
0733                 , o
0734                 , c
0735                 );
0736         }
0737     };
0738 
0739     struct inplace_merge 
0740     {
0741         typedef void result_type;
0742 
0743         template<class R, class M>
0744         void operator()(R& r, M m) const
0745         {
0746             return std::inplace_merge(detail::begin_(r), m, detail::end_(r));
0747         }
0748 
0749         template<class R, class M, class C>
0750         void operator()(R& r, M m, C c) const
0751         {
0752             return std::inplace_merge(detail::begin_(r), m, detail::end_(r), c);
0753         }
0754     };
0755 
0756     struct next_permutation
0757     {
0758         typedef bool result_type;
0759 
0760         template<class R>
0761         bool operator()(R& r) const
0762         {
0763             return std::next_permutation(detail::begin_(r), detail::end_(r));
0764         }
0765     
0766         template<class R, class C>
0767         bool operator()(R& r, C c) const
0768         {
0769             return std::next_permutation(detail::begin_(r), detail::end_(r), c);
0770         }
0771     };
0772 
0773     struct prev_permutation
0774     {
0775         typedef bool result_type;
0776 
0777         template<class R>
0778         bool operator()(R& r) const
0779         {
0780             return std::prev_permutation(detail::begin_(r), detail::end_(r));
0781         }
0782     
0783         template<class R, class C>
0784         bool operator()(R& r, C c) const
0785         {
0786             return std::prev_permutation(detail::begin_(r), detail::end_(r), c);
0787         }
0788     };
0789 
0790 
0791     struct inner_product
0792     {
0793         template <typename Sig>
0794         struct result;
0795 
0796         template <typename This, typename R, typename I, typename T>
0797         struct result<This(R&, I, T)>
0798             : result<This(R&, I const &, T)>
0799         {};
0800 
0801         template <typename This, typename R, typename I, typename T>
0802         struct result<This(R&, I, T &)>
0803         {
0804             typedef T type;
0805         };
0806 
0807         template <typename This, typename R, typename I, typename T, typename C1, typename C2>
0808         struct result<This(R&, I, T, C1, C2)>
0809             : result<This(R&, I, T const &, C1, C2)>
0810         {};
0811 
0812         template <typename This, typename R, typename I, typename T, typename C1, typename C2>
0813         struct result<This(R&, I, T &, C1, C2)>
0814         {
0815             typedef T type;
0816         };
0817 
0818         template <class R, class I, class T>
0819         T
0820         operator()(R& r, I i, T t) const
0821         {
0822             return std::inner_product(
0823                 detail::begin_(r), detail::end_(r), i, t);
0824         }
0825 
0826         template <class R, class I, class T, class C1, class C2>
0827         T
0828         operator()(R& r, I i, T t, C1 c1, C2 c2) const
0829         {
0830             return std::inner_product(
0831                 detail::begin_(r), detail::end_(r), i, 
0832                 t, c1, c2);
0833         }
0834     };
0835 
0836     struct partial_sum
0837     {
0838         template <typename Sig>
0839         struct result;
0840 
0841         template <typename This, class R, class I>
0842         struct result<This(R&, I)>
0843             : detail::decay_array<I>
0844         {};
0845 
0846         template <typename This, class R, class I, class C>
0847         struct result<This(R&, I, C)>
0848             : detail::decay_array<I>
0849         {};
0850 
0851         template <class R, class I>
0852         typename detail::decay_array<I>::type
0853         operator()(R& r, I i) const
0854         {
0855             return std::partial_sum(
0856                 detail::begin_(r), detail::end_(r), i);
0857         }
0858 
0859         template <class R, class I, class C>
0860         typename detail::decay_array<I>::type
0861         operator()(R& r, I i, C c) const
0862         {
0863             return std::partial_sum(
0864                 detail::begin_(r), detail::end_(r), i, c);
0865         }
0866     };
0867 
0868     struct adjacent_difference
0869     {
0870         template <typename Sig>
0871         struct result;
0872         
0873         template <typename This, class R, class I>
0874         struct result<This(R&, I)>
0875             : detail::decay_array<I>
0876         {};
0877 
0878         template <typename This,class R, class I, class C>
0879         struct result<This(R&, I, C)>
0880             : detail::decay_array<I>
0881         {};
0882 
0883         template <class R, class I>
0884         typename detail::decay_array<I>::type
0885         operator()(R& r, I i) const
0886         {
0887             return std::adjacent_difference(
0888                 detail::begin_(r), detail::end_(r), i);
0889         }
0890 
0891         template <class R, class I, class C>
0892         typename detail::decay_array<I>::type
0893         operator()(R& r, I i, C c) const
0894         {
0895             return std::adjacent_difference(
0896                 detail::begin_(r), detail::end_(r), i, c);
0897         }    
0898     };
0899 
0900     struct push_heap
0901     {
0902         typedef void result_type;
0903 
0904         template <class R>
0905         void operator()(R& r) const
0906         {
0907             std::push_heap(detail::begin_(r), detail::end_(r));
0908         }
0909 
0910         template <class R, class C>
0911         void operator()(R& r, C c) const
0912         {
0913             std::push_heap(detail::begin_(r), detail::end_(r), c);
0914         }
0915     };
0916 
0917     struct pop_heap
0918     {
0919         typedef void result_type;
0920 
0921         template <class R>
0922         void operator()(R& r) const
0923         {
0924             std::pop_heap(detail::begin_(r), detail::end_(r));
0925         }
0926 
0927         template <class R, class C>
0928         void operator()(R& r, C c) const
0929         {
0930             std::pop_heap(detail::begin_(r), detail::end_(r), c);
0931         }
0932     };
0933 
0934     struct make_heap
0935     {
0936         typedef void result_type;
0937 
0938         template <class R>
0939         void operator()(R& r) const
0940         {
0941             std::make_heap(detail::begin_(r), detail::end_(r));
0942         }
0943 
0944         template <class R, class C>
0945         void operator()(R& r, C c) const
0946         {
0947             std::make_heap(detail::begin_(r), detail::end_(r), c);
0948         }
0949     };
0950 
0951     struct sort_heap
0952     {
0953         typedef void result_type;
0954 
0955         template <class R>
0956         void operator()(R& r) const
0957         {
0958             std::sort_heap(detail::begin_(r), detail::end_(r));
0959         }
0960 
0961         template <class R, class C>
0962         void operator()(R& r, C c) const
0963         {
0964             std::sort_heap(detail::begin_(r), detail::end_(r), c);
0965         }
0966     };
0967 
0968     struct set_union
0969     {
0970         template <typename Sig>
0971         struct result;
0972 
0973         template <typename This, class R1, class R2, class O>
0974         struct result<This(R1&, R2&, O)>
0975             : detail::decay_array<O>
0976         {};
0977 
0978         template <typename This, class R1, class R2, class O, typename C>
0979         struct result<This(R1&, R2&, O, C)>
0980             : detail::decay_array<O>
0981         {};
0982 
0983         template <class R1, class R2, class O>
0984         typename detail::decay_array<O>::type
0985         operator()(R1& r1, R2& r2, O o) const
0986         {
0987             return std::set_union(
0988                 detail::begin_(r1), detail::end_(r1)
0989                 , detail::begin_(r2), detail::end_(r2)
0990                 , o
0991                 );
0992         }
0993 
0994         template <class R1, class R2, class O, class C>
0995         typename detail::decay_array<O>::type
0996         operator()(R1& r1, R2& r2, O o, C c) const
0997         {
0998             return std::set_union(
0999                 detail::begin_(r1), detail::end_(r1)
1000                 , detail::begin_(r2), detail::end_(r2)
1001                 , o
1002                 , c
1003                 );
1004         }
1005     };
1006 
1007     struct set_intersection
1008     {
1009         template <typename Sig>
1010         struct result;
1011 
1012         template <typename This, class R1, class R2, class O>
1013         struct result<This(R1&, R2&, O)>
1014             : detail::decay_array<O>
1015         {};
1016 
1017         template <typename This, class R1, class R2, class O, typename C>
1018         struct result<This(R1&, R2&, O, C)>
1019             : detail::decay_array<O>
1020         {};
1021 
1022         template <class R1, class R2, class O>
1023         typename detail::decay_array<O>::type
1024         operator()(R1& r1, R2& r2, O o) const
1025         {
1026             return std::set_intersection(
1027                 detail::begin_(r1), detail::end_(r1)
1028                 , detail::begin_(r2), detail::end_(r2)
1029                 , o
1030                 );
1031         }
1032 
1033         template <class R1, class R2, class O, class C>
1034         typename detail::decay_array<O>::type
1035         operator()(R1& r1, R2& r2, O o, C c) const
1036         {
1037             return std::set_intersection(
1038                 detail::begin_(r1), detail::end_(r1)
1039                 , detail::begin_(r2), detail::end_(r2)
1040                 , o
1041                 , c
1042                 );
1043         }
1044     };
1045 
1046     struct set_difference
1047     {
1048         template <typename Sig>
1049         struct result;
1050 
1051         template <typename This, class R1, class R2, class O>
1052         struct result<This(R1&, R2&, O)>
1053             : detail::decay_array<O>
1054         {};
1055 
1056         template <typename This, class R1, class R2, class O, class C>
1057         struct result<This(R1&, R2&, O, C)>
1058             : detail::decay_array<O>
1059         {};
1060 
1061         template <class R1, class R2, class O>
1062         typename detail::decay_array<O>::type
1063         operator()(R1& r1, R2& r2, O o) const
1064         {
1065             return std::set_difference(
1066                 detail::begin_(r1), detail::end_(r1)
1067                 , detail::begin_(r2), detail::end_(r2)
1068                 , o
1069                 );
1070         }
1071 
1072         template <class R1, class R2, class O, class C>
1073         typename detail::decay_array<O>::type
1074         operator()(R1& r1, R2& r2, O o, C c) const
1075         {
1076             return std::set_difference(
1077                 detail::begin_(r1), detail::end_(r1)
1078                 , detail::begin_(r2), detail::end_(r2)
1079                 , o
1080                 , c
1081                 );
1082         }
1083     };
1084 
1085     struct set_symmetric_difference
1086     {
1087         template <typename Sig>
1088         struct result;
1089 
1090         template <typename This, class R1, class R2, class O>
1091         struct result<This(R1&, R2, O)>
1092             : detail::decay_array<O>
1093         {};
1094 
1095         template <typename This, class R1, class R2, class O, class C>
1096         struct result<This(R1&, R2, O, C)>
1097             : detail::decay_array<O>
1098         {};
1099 
1100         template <class R1, class R2, class O>
1101         typename detail::decay_array<O>::type
1102         operator()(R1& r1, R2& r2, O o) const
1103         {
1104             return std::set_symmetric_difference(
1105                 detail::begin_(r1), detail::end_(r1)
1106                 , detail::begin_(r2), detail::end_(r2)
1107                 , o
1108                 );
1109         }
1110 
1111         template <class R1, class R2, class O, class C>
1112         typename detail::decay_array<O>::type
1113         operator()(R1& r1, R2& r2, O o, C c) const
1114         {
1115             return std::set_symmetric_difference(
1116                 detail::begin_(r1), detail::end_(r1)
1117                 , detail::begin_(r2), detail::end_(r2)
1118                 , o
1119                 , c
1120                 );
1121         }
1122     };
1123 
1124 }}} // boost::phoenix::impl
1125 
1126 namespace boost { namespace phoenix
1127 {
1128     BOOST_PHOENIX_ADAPT_CALLABLE(swap, impl::swap, 2)
1129     BOOST_PHOENIX_ADAPT_CALLABLE(copy, impl::copy, 2)
1130     BOOST_PHOENIX_ADAPT_CALLABLE(copy_backward, impl::copy_backward, 2)
1131     BOOST_PHOENIX_ADAPT_CALLABLE(transform, impl::transform, 3)
1132     BOOST_PHOENIX_ADAPT_CALLABLE(transform, impl::transform, 4)
1133     BOOST_PHOENIX_ADAPT_CALLABLE(replace, impl::replace, 3)
1134     BOOST_PHOENIX_ADAPT_CALLABLE(replace_if, impl::replace_if, 3)
1135     BOOST_PHOENIX_ADAPT_CALLABLE(replace_copy, impl::replace_copy, 4)
1136     BOOST_PHOENIX_ADAPT_CALLABLE(replace_copy_if, impl::replace_copy_if, 4)
1137     BOOST_PHOENIX_ADAPT_CALLABLE(fill, impl::fill, 2)
1138     BOOST_PHOENIX_ADAPT_CALLABLE(fill_n, impl::fill_n, 3)
1139     BOOST_PHOENIX_ADAPT_CALLABLE(generate, impl::generate, 2)
1140     BOOST_PHOENIX_ADAPT_CALLABLE(generate_n, impl::generate_n, 3)
1141     BOOST_PHOENIX_ADAPT_CALLABLE(remove, impl::remove, 2)
1142     BOOST_PHOENIX_ADAPT_CALLABLE(remove_if, impl::remove_if, 2)
1143     BOOST_PHOENIX_ADAPT_CALLABLE(remove_copy, impl::remove_copy, 3)
1144     BOOST_PHOENIX_ADAPT_CALLABLE(remove_copy_if, impl::remove_copy_if, 3)
1145     BOOST_PHOENIX_ADAPT_CALLABLE(unique, impl::unique, 1)
1146     BOOST_PHOENIX_ADAPT_CALLABLE(unique, impl::unique, 2)
1147     BOOST_PHOENIX_ADAPT_CALLABLE(unique_copy, impl::unique_copy, 2)
1148     BOOST_PHOENIX_ADAPT_CALLABLE(unique_copy, impl::unique_copy, 3)
1149     BOOST_PHOENIX_ADAPT_CALLABLE(reverse, impl::reverse, 1)
1150     BOOST_PHOENIX_ADAPT_CALLABLE(reverse_copy, impl::reverse_copy, 2)
1151     BOOST_PHOENIX_ADAPT_CALLABLE(rotate, impl::rotate, 2)
1152     BOOST_PHOENIX_ADAPT_CALLABLE(rotate_copy, impl::rotate_copy, 3)
1153 #ifndef BOOST_NO_CXX98_RANDOM_SHUFFLE
1154     BOOST_PHOENIX_ADAPT_CALLABLE(random_shuffle, impl::random_shuffle, 1)
1155     BOOST_PHOENIX_ADAPT_CALLABLE(random_shuffle, impl::random_shuffle, 2)
1156 #endif
1157     BOOST_PHOENIX_ADAPT_CALLABLE(partition, impl::partition, 2)
1158     BOOST_PHOENIX_ADAPT_CALLABLE(stable_partition, impl::stable_partition, 2)
1159     BOOST_PHOENIX_ADAPT_CALLABLE(sort, impl::sort, 1)
1160     BOOST_PHOENIX_ADAPT_CALLABLE(sort, impl::sort, 2)
1161     BOOST_PHOENIX_ADAPT_CALLABLE(stable_sort, impl::stable_sort, 1)
1162     BOOST_PHOENIX_ADAPT_CALLABLE(stable_sort, impl::stable_sort, 2)
1163     BOOST_PHOENIX_ADAPT_CALLABLE(partial_sort, impl::partial_sort, 2)
1164     BOOST_PHOENIX_ADAPT_CALLABLE(partial_sort, impl::partial_sort, 3)
1165     BOOST_PHOENIX_ADAPT_CALLABLE(partial_sort_copy, impl::partial_sort_copy, 2)
1166     BOOST_PHOENIX_ADAPT_CALLABLE(partial_sort_copy, impl::partial_sort_copy, 3)
1167     BOOST_PHOENIX_ADAPT_CALLABLE(nth_element, impl::nth_element, 2)
1168     BOOST_PHOENIX_ADAPT_CALLABLE(nth_element, impl::nth_element, 3)
1169     BOOST_PHOENIX_ADAPT_CALLABLE(merge, impl::merge, 3)
1170     BOOST_PHOENIX_ADAPT_CALLABLE(merge, impl::merge, 4)
1171     BOOST_PHOENIX_ADAPT_CALLABLE(inplace_merge, impl::inplace_merge, 2)
1172     BOOST_PHOENIX_ADAPT_CALLABLE(inplace_merge, impl::inplace_merge, 3)
1173     BOOST_PHOENIX_ADAPT_CALLABLE(next_permutation, impl::next_permutation, 1)
1174     BOOST_PHOENIX_ADAPT_CALLABLE(next_permutation, impl::next_permutation, 2)
1175     BOOST_PHOENIX_ADAPT_CALLABLE(prev_permutation, impl::prev_permutation, 1)
1176     BOOST_PHOENIX_ADAPT_CALLABLE(prev_permutation, impl::prev_permutation, 2)
1177     BOOST_PHOENIX_ADAPT_CALLABLE(inner_product, impl::inner_product, 3)
1178     BOOST_PHOENIX_ADAPT_CALLABLE(inner_product, impl::inner_product, 5)
1179     BOOST_PHOENIX_ADAPT_CALLABLE(partial_sum, impl::partial_sum, 2)
1180     BOOST_PHOENIX_ADAPT_CALLABLE(partial_sum, impl::partial_sum, 3)
1181     BOOST_PHOENIX_ADAPT_CALLABLE(adjacent_difference, impl::adjacent_difference, 2)
1182     BOOST_PHOENIX_ADAPT_CALLABLE(adjacent_difference, impl::adjacent_difference, 3)
1183     BOOST_PHOENIX_ADAPT_CALLABLE(push_heap, impl::push_heap, 1)
1184     BOOST_PHOENIX_ADAPT_CALLABLE(push_heap, impl::push_heap, 2)
1185     BOOST_PHOENIX_ADAPT_CALLABLE(pop_heap, impl::pop_heap, 1)
1186     BOOST_PHOENIX_ADAPT_CALLABLE(pop_heap, impl::pop_heap, 2)
1187     BOOST_PHOENIX_ADAPT_CALLABLE(make_heap, impl::make_heap, 1)
1188     BOOST_PHOENIX_ADAPT_CALLABLE(make_heap, impl::make_heap, 2)
1189     BOOST_PHOENIX_ADAPT_CALLABLE(sort_heap, impl::sort_heap, 1)
1190     BOOST_PHOENIX_ADAPT_CALLABLE(sort_heap, impl::sort_heap, 2)
1191     BOOST_PHOENIX_ADAPT_CALLABLE(set_union, impl::set_union, 3)
1192     BOOST_PHOENIX_ADAPT_CALLABLE(set_union, impl::set_union, 4)
1193     BOOST_PHOENIX_ADAPT_CALLABLE(set_intersection, impl::set_intersection, 3)
1194     BOOST_PHOENIX_ADAPT_CALLABLE(set_intersection, impl::set_intersection, 4)
1195     BOOST_PHOENIX_ADAPT_CALLABLE(set_difference, impl::set_difference, 3)
1196     BOOST_PHOENIX_ADAPT_CALLABLE(set_difference, impl::set_difference, 4)
1197     BOOST_PHOENIX_ADAPT_CALLABLE(set_symmetric_difference, impl::set_symmetric_difference, 3)
1198     BOOST_PHOENIX_ADAPT_CALLABLE(set_symmetric_difference, impl::set_symmetric_difference, 4)
1199 }}
1200 
1201 #endif