replace_copy.hpp 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  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_HPP_INCLUDED
  10. #define BOOST_RANGE_ALGORITHM_REPLACE_COPY_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
  21. ///
  22. /// range-based version of the replace_copy std algorithm
  23. ///
  24. /// \pre ForwardRange is a model of the ForwardRangeConcept
  25. template< class ForwardRange, class OutputIterator, class Value >
  26. inline OutputIterator
  27. replace_copy(const ForwardRange& rng, OutputIterator out_it, const Value& what,
  28. const Value& with_what)
  29. {
  30. BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept<const ForwardRange> ));
  31. return std::replace_copy(boost::begin(rng), boost::end(rng), out_it,
  32. what, with_what);
  33. }
  34. } // namespace range
  35. using range::replace_copy;
  36. } // namespace boost
  37. #endif // include guard