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