1 | /*============================================================================= |
---|
2 | Copyright (c) 2003 Joel de Guzman |
---|
3 | Copyright (c) 2004 Peder Holt |
---|
4 | |
---|
5 | Use, modification and distribution is subject to the Boost Software |
---|
6 | License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at |
---|
7 | http://www.boost.org/LICENSE_1_0.txt) |
---|
8 | ==============================================================================*/ |
---|
9 | #if !defined(FUSION_ALGORITHM_ERASE_HPP) |
---|
10 | #define FUSION_ALGORITHM_ERASE_HPP |
---|
11 | |
---|
12 | #include <boost/spirit/fusion/sequence/single_view.hpp> |
---|
13 | #include <boost/spirit/fusion/sequence/joint_view.hpp> |
---|
14 | #include <boost/spirit/fusion/sequence/range.hpp> |
---|
15 | #include <boost/spirit/fusion/sequence/begin.hpp> |
---|
16 | #include <boost/spirit/fusion/sequence/end.hpp> |
---|
17 | #include <boost/spirit/fusion/iterator/next.hpp> |
---|
18 | #include <boost/spirit/fusion/iterator/equal_to.hpp> |
---|
19 | |
---|
20 | namespace boost { namespace fusion |
---|
21 | { |
---|
22 | namespace meta |
---|
23 | { |
---|
24 | template <typename Sequence, typename Position> |
---|
25 | struct erase |
---|
26 | { |
---|
27 | typedef typename meta::begin<Sequence>::type first_type; |
---|
28 | typedef typename meta::end<Sequence>::type last_type; |
---|
29 | #if! BOOST_WORKAROUND(BOOST_MSVC,<=1300) |
---|
30 | BOOST_STATIC_ASSERT((!meta::equal_to<Position, last_type>::value)); |
---|
31 | #endif |
---|
32 | |
---|
33 | typedef typename meta::next<Position>::type next_type; |
---|
34 | typedef range<first_type, Position> left_type; |
---|
35 | typedef range<next_type, last_type> right_type; |
---|
36 | typedef joint_view<left_type, right_type> type; |
---|
37 | }; |
---|
38 | } |
---|
39 | |
---|
40 | namespace function |
---|
41 | { |
---|
42 | struct erase |
---|
43 | { |
---|
44 | template <typename Sequence, typename Position> |
---|
45 | struct apply : meta::erase<Sequence, Position> {}; |
---|
46 | |
---|
47 | template <typename Sequence, typename Position> |
---|
48 | typename apply<Sequence const, Position>::type |
---|
49 | operator()(Sequence const& seq, Position const& pos) const |
---|
50 | { |
---|
51 | typedef apply<Sequence const, Position> meta_type; |
---|
52 | typedef typename meta_type::left_type left_type; |
---|
53 | typedef typename meta_type::right_type right_type; |
---|
54 | typedef typename meta_type::type result_type; |
---|
55 | |
---|
56 | left_type left(fusion::begin(seq), pos); |
---|
57 | right_type right(fusion::next(pos), fusion::end(seq)); |
---|
58 | return result_type(left, right); |
---|
59 | } |
---|
60 | |
---|
61 | // template <typename Sequence, typename Position> |
---|
62 | // typename apply<Sequence, Position>::type |
---|
63 | // operator()(Sequence& seq, Position const& pos) const |
---|
64 | // { |
---|
65 | // typedef apply<Sequence, Position> meta; |
---|
66 | // typedef typename meta::left_type left_type; |
---|
67 | // typedef typename meta::right_type right_type; |
---|
68 | // typedef typename meta::type result_type; |
---|
69 | // |
---|
70 | // left_type left(fusion::begin(seq), pos); |
---|
71 | // right_type right(fusion::next(pos), fusion::end(seq)); |
---|
72 | // return result_type(left, right); |
---|
73 | // } |
---|
74 | }; |
---|
75 | } |
---|
76 | |
---|
77 | function::erase const erase = function::erase(); |
---|
78 | }} |
---|
79 | |
---|
80 | #endif |
---|
81 | |
---|