1 | /*=============================================================================
|
---|
2 | Copyright (c) 2003 Joel de Guzman
|
---|
3 |
|
---|
4 | Use, modification and distribution is subject to the Boost Software
|
---|
5 | License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
---|
6 | http://www.boost.org/LICENSE_1_0.txt)
|
---|
7 | ==============================================================================*/
|
---|
8 | #if !defined(FUSION_ALGORITHM_REMOVE_IF_HPP)
|
---|
9 | #define FUSION_ALGORITHM_REMOVE_IF_HPP
|
---|
10 |
|
---|
11 | #include <boost/spirit/fusion/sequence/filter_view.hpp>
|
---|
12 | #include <boost/mpl/not.hpp>
|
---|
13 |
|
---|
14 | namespace boost { namespace fusion
|
---|
15 | {
|
---|
16 | namespace meta
|
---|
17 | {
|
---|
18 | template <typename Sequence, typename Pred>
|
---|
19 | struct remove_if
|
---|
20 | {
|
---|
21 | typedef filter_view<Sequence, mpl::not_<Pred> > type;
|
---|
22 | };
|
---|
23 | }
|
---|
24 |
|
---|
25 | namespace function
|
---|
26 | {
|
---|
27 | struct remove_if
|
---|
28 | {
|
---|
29 | template <typename Sequence, typename Pred>
|
---|
30 | struct apply : meta::remove_if<Sequence, Pred> {};
|
---|
31 |
|
---|
32 | template <typename Sequence, typename Pred>
|
---|
33 | inline typename apply<Sequence const, Pred>::type
|
---|
34 | operator()(Sequence const& seq, Pred) const
|
---|
35 | {
|
---|
36 | return filter_view<Sequence const, mpl::not_<Pred> >(seq);
|
---|
37 | }
|
---|
38 |
|
---|
39 | template <typename Sequence, typename Pred>
|
---|
40 | inline typename apply<Sequence, Pred>::type
|
---|
41 | operator()(Sequence& seq, Pred) const
|
---|
42 | {
|
---|
43 | return filter_view<Sequence, mpl::not_<Pred> >(seq);
|
---|
44 | }
|
---|
45 | };
|
---|
46 | }
|
---|
47 |
|
---|
48 | function::remove_if const remove_if = function::remove_if();
|
---|
49 | }}
|
---|
50 |
|
---|
51 | #endif
|
---|
52 |
|
---|