2 #ifndef BOOST_MPL_AUX_SORT_IMPL_HPP_INCLUDED
3 #define BOOST_MPL_AUX_SORT_IMPL_HPP_INCLUDED
5 // Copyright Eric Friedman 2002-2003
7 // Distributed under the Boost Software License, Version 1.0.
8 // (See accompanying file LICENSE_1_0.txt or copy at
9 // http://www.boost.org/LICENSE_1_0.txt)
11 // See http://www.boost.org/libs/mpl for documentation.
17 #include <boost/mpl/partition.hpp>
18 #include <boost/mpl/copy.hpp>
19 #include <boost/mpl/vector.hpp>
20 #include <boost/mpl/back_inserter.hpp>
21 #include <boost/mpl/front_inserter.hpp>
22 #include <boost/mpl/iterator_range.hpp>
23 #include <boost/mpl/joint_view.hpp>
24 #include <boost/mpl/single_view.hpp>
25 #include <boost/mpl/begin_end.hpp>
26 #include <boost/mpl/empty.hpp>
27 #include <boost/mpl/deref.hpp>
28 #include <boost/mpl/eval_if.hpp>
29 #include <boost/mpl/apply.hpp>
30 #include <boost/mpl/identity.hpp>
31 #include <boost/mpl/less.hpp>
32 #include <boost/mpl/aux_/na.hpp>
34 namespace boost { namespace mpl { namespace aux {
36 template< typename Seq, typename Pred >
39 // agurt, 10/nov/04: for the sake of deficeint compilers
40 template< typename Pred, typename Pivot >
41 struct quick_sort_pred
43 template< typename T > struct apply
45 typedef typename apply2<Pred,T,Pivot>::type type;
53 struct quick_sort_impl
55 typedef typename begin<Seq>::type pivot;
56 typedef typename partition<
58 typename next<pivot>::type
59 , typename end<Seq>::type
61 , protect< aux::quick_sort_pred< Pred, typename deref<pivot>::type > >
62 , back_inserter< vector<> >
63 , back_inserter< vector<> >
66 typedef typename quick_sort< typename partitioned::first, Pred >::type part1;
67 typedef typename quick_sort< typename partitioned::second, Pred >::type part2;
70 joint_view< part1, single_view< typename deref<pivot>::type > >
83 , quick_sort_impl<Seq,Pred>
96 typedef typename quick_sort<
98 , typename if_na<Pred,less<> >::type
101 typedef typename copy<result_,In>::type type;
109 struct reverse_sort_impl
111 typedef typename quick_sort<
113 , typename if_na<Pred,less<> >::type
116 typedef typename reverse_copy<result_,In>::type type;
121 #endif // BOOST_MPL_AUX_SORT_IMPL_HPP_INCLUDED