Imported Upstream version 1.57.0
[platform/upstream/boost.git] / boost / mpl / aux_ / erase_impl.hpp
1
2 #ifndef BOOST_MPL_AUX_ERASE_IMPL_HPP_INCLUDED
3 #define BOOST_MPL_AUX_ERASE_IMPL_HPP_INCLUDED
4
5 // Copyright Aleksey Gurtovoy 2000-2004
6 //
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)
10 //
11 // See http://www.boost.org/libs/mpl for documentation.
12
13 // $Id$
14 // $Date$
15 // $Revision$
16
17 #include <boost/mpl/clear.hpp>
18 #include <boost/mpl/push_front.hpp>
19 #include <boost/mpl/reverse_fold.hpp>
20 #include <boost/mpl/iterator_range.hpp>
21 #include <boost/mpl/next.hpp>
22 #include <boost/mpl/aux_/na.hpp>
23
24 namespace boost { namespace mpl {
25
26 // default implementation; conrete sequences might override it by 
27 // specializing either the 'erase_impl' or the primary 'erase' template
28
29 template< typename Tag >
30 struct erase_impl
31 {
32     template<
33           typename Sequence
34         , typename First
35         , typename Last
36         >
37     struct apply
38     {
39         typedef typename if_na< Last,typename next<First>::type >::type last_;
40         
41         // 1st half: [begin, first)
42         typedef iterator_range<
43               typename begin<Sequence>::type
44             , First
45             > first_half_;
46
47         // 2nd half: [last, end) ... that is, [last + 1, end)
48         typedef iterator_range<
49               last_
50             , typename end<Sequence>::type
51             > second_half_;
52
53         typedef typename reverse_fold<
54               second_half_
55             , typename clear<Sequence>::type
56             , push_front<_,_>
57             >::type half_sequence_;
58
59         typedef typename reverse_fold<
60               first_half_
61             , half_sequence_
62             , push_front<_,_>
63             >::type type;
64     };
65 };
66
67 }}
68
69 #endif // BOOST_MPL_AUX_ERASE_IMPL_HPP_INCLUDED