replace_copy_if.hpp 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  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. #include <boost/concept_check.hpp>
  12. #include <boost/range/begin.hpp>
  13. #include <boost/range/end.hpp>
  14. #include <boost/range/concepts.hpp>
  15. #include <algorithm>
  16. namespace boost
  17. {
  18. namespace range
  19. {
  20. /// \brief template function replace_copy_if
  21. ///
  22. /// range-based version of the replace_copy_if std algorithm
  23. ///
  24. /// \pre ForwardRange is a model of the ForwardRangeConcept
  25. /// \pre Predicate is a model of the PredicateConcept
  26. /// \pre Value is convertible to Predicate's argument type
  27. /// \pre Value is Assignable
  28. /// \pre Value is convertible to a type in OutputIterator's set of value types.
  29. template< class ForwardRange, class OutputIterator, class Predicate, class Value >
  30. inline OutputIterator
  31. replace_copy_if(const ForwardRange& rng, OutputIterator out_it, Predicate pred,
  32. const Value& with_what)
  33. {
  34. BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept<const ForwardRange> ));
  35. return std::replace_copy_if(boost::begin(rng), boost::end(rng), out_it,
  36. pred, with_what);
  37. }
  38. } // namespace range
  39. using range::replace_copy_if;
  40. } // namespace boost
  41. #endif // include guard