1 // Copyright Neil Groves 2009. Use, modification and
2 // distribution is subject to the Boost Software License, Version
3 // 1.0. (See accompanying file LICENSE_1_0.txt or copy at
4 // http://www.boost.org/LICENSE_1_0.txt)
7 // For more information, see http://www.boost.org/libs/range/
9 #ifndef BOOST_RANGE_ALGORITHM_REMOVE_HPP_INCLUDED
10 #define BOOST_RANGE_ALGORITHM_REMOVE_HPP_INCLUDED
12 #include <boost/concept_check.hpp>
13 #include <boost/range/begin.hpp>
14 #include <boost/range/end.hpp>
15 #include <boost/range/concepts.hpp>
16 #include <boost/range/detail/range_return.hpp>
24 /// \brief template function remove
26 /// range-based version of the remove std algorithm
28 /// \pre ForwardRange is a model of the ForwardRangeConcept
29 template< class ForwardRange, class Value >
30 inline BOOST_DEDUCED_TYPENAME range_iterator<ForwardRange>::type
31 remove(ForwardRange& rng, const Value& val)
33 BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept<ForwardRange> ));
34 return std::remove(boost::begin(rng),boost::end(rng),val);
38 template< class ForwardRange, class Value >
39 inline BOOST_DEDUCED_TYPENAME range_iterator<const ForwardRange>::type
40 remove(const ForwardRange& rng, const Value& val)
42 BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept<const ForwardRange> ));
43 return std::remove(boost::begin(rng),boost::end(rng),val);
46 // range_return overloads
49 template< range_return_value re, class ForwardRange, class Value >
50 inline BOOST_DEDUCED_TYPENAME range_return<ForwardRange,re>::type
51 remove(ForwardRange& rng, const Value& val)
53 BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept<ForwardRange> ));
54 return range_return<ForwardRange,re>::pack(
55 std::remove(boost::begin(rng), boost::end(rng), val),
60 template< range_return_value re, class ForwardRange, class Value >
61 inline BOOST_DEDUCED_TYPENAME range_return<const ForwardRange,re>::type
62 remove(const ForwardRange& rng, const Value& val)
64 BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept<const ForwardRange> ));
65 return range_return<const ForwardRange,re>::pack(
66 std::remove(boost::begin(rng), boost::end(rng), val),
74 #endif // include guard