Chris@16
|
1
|
Chris@16
|
2 #ifndef BOOST_MPL_UNIQUE_HPP_INCLUDED
|
Chris@16
|
3 #define BOOST_MPL_UNIQUE_HPP_INCLUDED
|
Chris@16
|
4
|
Chris@16
|
5 // Copyright Aleksey Gurtovoy 2000-2004
|
Chris@16
|
6 // Copyright John R. Bandela 2000-2002
|
Chris@16
|
7 //
|
Chris@16
|
8 // Distributed under the Boost Software License, Version 1.0.
|
Chris@16
|
9 // (See accompanying file LICENSE_1_0.txt or copy at
|
Chris@16
|
10 // http://www.boost.org/LICENSE_1_0.txt)
|
Chris@16
|
11 //
|
Chris@16
|
12 // See http://www.boost.org/libs/mpl for documentation.
|
Chris@16
|
13
|
Chris@101
|
14 // $Id$
|
Chris@101
|
15 // $Date$
|
Chris@101
|
16 // $Revision$
|
Chris@16
|
17
|
Chris@16
|
18 #include <boost/mpl/fold.hpp>
|
Chris@16
|
19 #include <boost/mpl/reverse_fold.hpp>
|
Chris@16
|
20 #include <boost/mpl/eval_if.hpp>
|
Chris@16
|
21 #include <boost/mpl/and.hpp>
|
Chris@16
|
22 #include <boost/mpl/identity.hpp>
|
Chris@16
|
23 #include <boost/mpl/pair.hpp>
|
Chris@16
|
24 #include <boost/mpl/apply.hpp>
|
Chris@16
|
25 #include <boost/mpl/aux_/inserter_algorithm.hpp>
|
Chris@16
|
26 #include <boost/mpl/aux_/na.hpp>
|
Chris@16
|
27 #include <boost/mpl/aux_/na_spec.hpp>
|
Chris@16
|
28 #include <boost/mpl/aux_/lambda_spec.hpp>
|
Chris@16
|
29
|
Chris@16
|
30 namespace boost { namespace mpl {
|
Chris@16
|
31
|
Chris@16
|
32 namespace aux {
|
Chris@16
|
33
|
Chris@16
|
34 template< typename Predicate, typename Operation >
|
Chris@16
|
35 struct unique_op
|
Chris@16
|
36 {
|
Chris@16
|
37 template< typename Pair, typename T > struct apply
|
Chris@16
|
38 {
|
Chris@16
|
39 typedef typename Pair::first seq_;
|
Chris@16
|
40 typedef typename Pair::second prior_;
|
Chris@16
|
41 typedef typename eval_if<
|
Chris@16
|
42 and_< is_not_na<prior_>, apply2<Predicate,prior_,T> >
|
Chris@16
|
43 , identity<seq_>
|
Chris@16
|
44 , apply2<Operation,seq_,T>
|
Chris@16
|
45 >::type new_seq_;
|
Chris@16
|
46
|
Chris@16
|
47 typedef pair<new_seq_,T> type;
|
Chris@16
|
48 };
|
Chris@16
|
49 };
|
Chris@16
|
50
|
Chris@16
|
51 template<
|
Chris@16
|
52 typename Sequence
|
Chris@16
|
53 , typename Predicate
|
Chris@16
|
54 , typename Inserter
|
Chris@16
|
55 >
|
Chris@16
|
56 struct unique_impl
|
Chris@16
|
57 : first< typename fold<
|
Chris@16
|
58 Sequence
|
Chris@16
|
59 , pair< typename Inserter::state,na >
|
Chris@16
|
60 , protect< aux::unique_op<Predicate,typename Inserter::operation> >
|
Chris@16
|
61 >::type >
|
Chris@16
|
62 {
|
Chris@16
|
63 };
|
Chris@16
|
64
|
Chris@16
|
65 template<
|
Chris@16
|
66 typename Sequence
|
Chris@16
|
67 , typename Predicate
|
Chris@16
|
68 , typename Inserter
|
Chris@16
|
69 >
|
Chris@16
|
70 struct reverse_unique_impl
|
Chris@16
|
71 : first< typename reverse_fold<
|
Chris@16
|
72 Sequence
|
Chris@16
|
73 , pair< typename Inserter::state,na >
|
Chris@16
|
74 , protect< aux::unique_op<Predicate,typename Inserter::operation> >
|
Chris@16
|
75 >::type >
|
Chris@16
|
76 {
|
Chris@16
|
77 };
|
Chris@16
|
78
|
Chris@16
|
79 } // namespace aux
|
Chris@16
|
80
|
Chris@16
|
81 BOOST_MPL_AUX_INSERTER_ALGORITHM_DEF(3, unique)
|
Chris@16
|
82
|
Chris@16
|
83 }}
|
Chris@16
|
84
|
Chris@16
|
85 #endif // BOOST_MPL_UNIQUE_HPP_INCLUDED
|