~ubuntu-branches/ubuntu/breezy/aqsis/breezy

« back to all changes in this revision

Viewing changes to boost/boost/mpl/unique.hpp

  • Committer: Bazaar Package Importer
  • Author(s): Will Newton
  • Date: 2004-12-07 20:06:49 UTC
  • Revision ID: james.westby@ubuntu.com-20041207200649-fccswkrvp4oc8lmn
Tags: upstream-0.9.3
ImportĀ upstreamĀ versionĀ 0.9.3

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
//-----------------------------------------------------------------------------
 
2
// boost mpl/unique.hpp header file
 
3
// See http://www.boost.org for updates, documentation, and revision history.
 
4
//-----------------------------------------------------------------------------
 
5
//
 
6
// Copyright (c) 2000-02
 
7
// Aleksey Gurtovoy and John R. Bandela
 
8
//
 
9
// Permission to use, copy, modify, distribute and sell this software
 
10
// and its documentation for any purpose is hereby granted without fee, 
 
11
// provided that the above copyright notice appears in all copies and 
 
12
// that both the copyright notice and this permission notice appear in 
 
13
// supporting documentation. No representations are made about the 
 
14
// suitability of this software for any purpose. It is provided "as is" 
 
15
// without express or implied warranty.
 
16
 
 
17
#ifndef BOOST_MPL_UNIQUE_HPP_INCLUDED
 
18
#define BOOST_MPL_UNIQUE_HPP_INCLUDED
 
19
 
 
20
#include "boost/mpl/fold_backward.hpp"
 
21
#include "boost/mpl/push_front.hpp"
 
22
#include "boost/mpl/clear.hpp"
 
23
#include "boost/mpl/front.hpp"
 
24
#include "boost/mpl/identity.hpp"
 
25
#include "boost/mpl/pair.hpp"
 
26
#include "boost/mpl/select1st.hpp"
 
27
#include "boost/mpl/lambda.hpp"
 
28
#include "boost/mpl/apply_if.hpp"
 
29
#include "boost/mpl/apply.hpp"
 
30
#include "boost/mpl/void.hpp"
 
31
#include "boost/mpl/aux_/void_spec.hpp"
 
32
#include "boost/mpl/aux_/lambda_spec.hpp"
 
33
#include "boost/mpl/aux_/config/eti.hpp"
 
34
#include "boost/type_traits/is_same.hpp"
 
35
 
 
36
namespace boost {
 
37
namespace mpl {
 
38
 
 
39
namespace aux {
 
40
 
 
41
template< typename Predicate >
 
42
struct unique_op
 
43
{
 
44
    template< typename Pair, typename T > struct apply
 
45
    {
 
46
        typedef typename Pair::first seq_;
 
47
        typedef typename Pair::second prior_;
 
48
        typedef typename apply_if<
 
49
              typename apply2<Predicate,prior_,T>::type
 
50
            , identity<seq_>
 
51
            , push_front<seq_,T>
 
52
            >::type new_seq_;
 
53
 
 
54
        typedef pair<new_seq_,T> type;
 
55
    };
 
56
};
 
57
 
 
58
} // namespace aux
 
59
 
 
60
BOOST_MPL_AUX_PASS_THROUGH_LAMBDA_SPEC(1,aux::unique_op)
 
61
 
 
62
BOOST_MPL_AUX_AGLORITHM_NAMESPACE_BEGIN
 
63
 
 
64
template<
 
65
      typename BOOST_MPL_AUX_VOID_SPEC_PARAM(Sequence)
 
66
    , typename Predicate = is_same<_,_>
 
67
    >
 
68
struct unique
 
69
{
 
70
 private:
 
71
    struct none_;
 
72
    typedef typename lambda<Predicate>::type pred_;
 
73
    typedef typename clear<Sequence>::type result_;
 
74
    typedef typename fold_backward<
 
75
          Sequence
 
76
        , pair<result_,none_>
 
77
        , aux::unique_op<pred_>
 
78
        >::type fold_result_;
 
79
 
 
80
 public:
 
81
#if defined(BOOST_MPL_MSVC_60_ETI_BUG)
 
82
    // MSVC6.5 forces us to use 'select1st<fold_result_>::type' instead of 
 
83
    // simple 'fold_result_::first' here
 
84
    typedef typename select1st<fold_result_>::type type;
 
85
#else
 
86
    typedef typename fold_result_::first type;
 
87
#endif
 
88
};
 
89
 
 
90
BOOST_MPL_AUX_AGLORITHM_NAMESPACE_END
 
91
 
 
92
BOOST_MPL_AUX_ALGORITHM_VOID_SPEC(1, unique)
 
93
 
 
94
} // namespace mpl
 
95
} // namespace boost
 
96
 
 
97
#endif // BOOST_MPL_UNIQUE_HPP_INCLUDED