]> AND Private Git Repository - canny.git/blob - stc/exp/ml_stc_linux_make_v1.0/include/boost/mpl/unique.hpp
Logo AND Algorithmique Numérique Distribuée

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