1 | // Boost.Range library |
---|
2 | // |
---|
3 | // Copyright Neil Groves 2009. Use, modification and |
---|
4 | // distribution is subject to the Boost Software License, Version |
---|
5 | // 1.0. (See accompanying file LICENSE_1_0.txt or copy at |
---|
6 | // http://www.boost.org/LICENSE_1_0.txt) |
---|
7 | // |
---|
8 | // For more information, see http://www.boost.org/libs/range/ |
---|
9 | // |
---|
10 | #ifndef BOOST_RANGE_ALGORITHM_EXT_ERASE_HPP_INCLUDED |
---|
11 | #define BOOST_RANGE_ALGORITHM_EXT_ERASE_HPP_INCLUDED |
---|
12 | |
---|
13 | #include <boost/range/config.hpp> |
---|
14 | #include <boost/range/concepts.hpp> |
---|
15 | #include <boost/range/difference_type.hpp> |
---|
16 | #include <boost/range/iterator_range_core.hpp> |
---|
17 | #include <boost/range/begin.hpp> |
---|
18 | #include <boost/range/end.hpp> |
---|
19 | #include <boost/assert.hpp> |
---|
20 | |
---|
21 | namespace boost |
---|
22 | { |
---|
23 | namespace range |
---|
24 | { |
---|
25 | |
---|
26 | template< class Container > |
---|
27 | inline Container& erase( Container& on, |
---|
28 | iterator_range<BOOST_DEDUCED_TYPENAME Container::iterator> to_erase ) |
---|
29 | { |
---|
30 | BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept<Container> )); |
---|
31 | on.erase( boost::begin(to_erase), boost::end(to_erase) ); |
---|
32 | return on; |
---|
33 | } |
---|
34 | |
---|
35 | template< class Container, class T > |
---|
36 | inline Container& remove_erase( Container& on, const T& val ) |
---|
37 | { |
---|
38 | BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept<Container> )); |
---|
39 | on.erase( |
---|
40 | std::remove(boost::begin(on), boost::end(on), val), |
---|
41 | boost::end(on)); |
---|
42 | return on; |
---|
43 | } |
---|
44 | |
---|
45 | template< class Container, class Pred > |
---|
46 | inline Container& remove_erase_if( Container& on, Pred pred ) |
---|
47 | { |
---|
48 | BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept<Container> )); |
---|
49 | on.erase( |
---|
50 | std::remove_if(boost::begin(on), boost::end(on), pred), |
---|
51 | boost::end(on)); |
---|
52 | return on; |
---|
53 | } |
---|
54 | |
---|
55 | } // namespace range |
---|
56 | using range::erase; |
---|
57 | using range::remove_erase; |
---|
58 | using range::remove_erase_if; |
---|
59 | } // namespace boost |
---|
60 | |
---|
61 | #endif // include guard |
---|