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