3
// Copyright Thorsten Ottosen, Neil Groves 2006 - 2008. Use, modification and
4
// distribution is subject to the Boost Software License, Version
5
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
6
// http://www.boost.org/LICENSE_1_0.txt)
8
// For more information, see http://www.boost.org/libs/range/
11
#ifndef BOOST_RANGE_ADAPTOR_UNIQUED_IMPL_HPP
12
#define BOOST_RANGE_ADAPTOR_UNIQUED_IMPL_HPP
14
#include <mlib/range/adaptor/adjacent_filtered.hpp>
19
namespace range_detail
21
struct unique_forwarder { };
23
struct unique_not_equal_to
25
typedef bool result_type;
28
bool operator()( const T& l, const T& r ) const
34
template<class ForwardRng>
35
class unique_range : public adjacent_filter_range<unique_not_equal_to, ForwardRng, true>
37
typedef adjacent_filter_range<unique_not_equal_to, ForwardRng, true> base;
39
explicit unique_range(ForwardRng& rng)
40
: base(unique_not_equal_to(), rng)
45
template< class ForwardRng >
46
inline unique_range<ForwardRng>
47
operator|( ForwardRng& r,
50
return unique_range<ForwardRng>(r);
53
template< class ForwardRng >
54
inline unique_range<const ForwardRng>
55
operator|( const ForwardRng& r,
58
return unique_range<const ForwardRng>(r);
63
using range_detail::unique_range;
69
const range_detail::unique_forwarder uniqued =
70
range_detail::unique_forwarder();
73
template<class ForwardRange>
74
inline unique_range<ForwardRange>
75
unique(ForwardRange& rng)
77
return unique_range<ForwardRange>(rng);
80
template<class ForwardRange>
81
inline unique_range<const ForwardRange>
82
unique(const ForwardRange& rng)
84
return unique_range<const ForwardRange>(rng);