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) |
5 | // |
6 | // |
7 | // For more information, see http://www.boost.org/libs/range/ |
8 | // |
9 | #ifndef BOOST_RANGE_ALGORITHM_REPLACE_COPY_IF_HPP_INCLUDED |
10 | #define BOOST_RANGE_ALGORITHM_REPLACE_COPY_IF_HPP_INCLUDED |
11 | |
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 <algorithm> |
17 | |
18 | namespace boost |
19 | { |
20 | namespace range |
21 | { |
22 | |
23 | /// \brief template function replace_copy_if |
24 | /// |
25 | /// range-based version of the replace_copy_if std algorithm |
26 | /// |
27 | /// \pre ForwardRange is a model of the ForwardRangeConcept |
28 | /// \pre Predicate is a model of the PredicateConcept |
29 | /// \pre Value is convertible to Predicate's argument type |
30 | /// \pre Value is Assignable |
31 | /// \pre Value is convertible to a type in OutputIterator's set of value types. |
32 | template< class ForwardRange, class OutputIterator, class Predicate, class Value > |
33 | inline OutputIterator |
34 | replace_copy_if(const ForwardRange& rng, OutputIterator out_it, Predicate pred, |
35 | const Value& with_what) |
36 | { |
37 | BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept<const ForwardRange> )); |
38 | return std::replace_copy_if(boost::begin(rng), boost::end(rng), out_it, |
39 | pred, with_what); |
40 | } |
41 | |
42 | } // namespace range |
43 | using range::replace_copy_if; |
44 | } // namespace boost |
45 | |
46 | #endif // include guard |
47 | |