unique_copy.hpp 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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_UNIQUE_COPY_HPP_INCLUDED
  10. #define BOOST_RANGE_ALGORITHM_UNIQUE_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 unique_copy
  21. ///
  22. /// range-based version of the unique_copy std algorithm
  23. ///
  24. /// \pre SinglePassRange is a model of the SinglePassRangeConcept
  25. /// \pre OutputIterator is a model of the OutputIteratorConcept
  26. /// \pre BinaryPredicate is a model of the BinaryPredicateConcept
  27. template< class SinglePassRange, class OutputIterator >
  28. inline OutputIterator
  29. unique_copy( const SinglePassRange& rng, OutputIterator out_it )
  30. {
  31. BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept<const SinglePassRange> ));
  32. return std::unique_copy(boost::begin(rng), boost::end(rng), out_it);
  33. }
  34. /// \overload
  35. template< class SinglePassRange, class OutputIterator, class BinaryPredicate >
  36. inline OutputIterator
  37. unique_copy( const SinglePassRange& rng, OutputIterator out_it,
  38. BinaryPredicate pred )
  39. {
  40. BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept<const SinglePassRange> ));
  41. return std::unique_copy(boost::begin(rng), boost::end(rng), out_it, pred);
  42. }
  43. } // namespace range
  44. using range::unique_copy;
  45. } // namespace boost
  46. #endif // include guard