File indexing completed on 2025-01-18 09:51:14
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011 #ifndef BOOST_RANGE_ADAPTOR_UNIQUED_IMPL_HPP
0012 #define BOOST_RANGE_ADAPTOR_UNIQUED_IMPL_HPP
0013
0014 #include <boost/range/adaptor/adjacent_filtered.hpp>
0015 #include <boost/range/concepts.hpp>
0016
0017 namespace boost
0018 {
0019
0020 namespace range_detail
0021 {
0022 struct unique_forwarder { };
0023
0024 struct unique_not_equal_to
0025 {
0026 typedef bool result_type;
0027
0028 template< class T >
0029 bool operator()( const T& l, const T& r ) const
0030 {
0031 return !(l == r);
0032 }
0033 };
0034
0035 template<class ForwardRng>
0036 class uniqued_range : public adjacent_filtered_range<unique_not_equal_to, ForwardRng, true>
0037 {
0038 typedef adjacent_filtered_range<unique_not_equal_to, ForwardRng, true> base;
0039 public:
0040 explicit uniqued_range(ForwardRng& rng)
0041 : base(unique_not_equal_to(), rng)
0042 {
0043 }
0044 };
0045
0046 template< class ForwardRng >
0047 inline uniqued_range<ForwardRng>
0048 operator|( ForwardRng& r,
0049 unique_forwarder )
0050 {
0051 BOOST_RANGE_CONCEPT_ASSERT((ForwardRangeConcept<ForwardRng>));
0052 return uniqued_range<ForwardRng>(r);
0053 }
0054
0055 template< class ForwardRng >
0056 inline uniqued_range<const ForwardRng>
0057 operator|( const ForwardRng& r,
0058 unique_forwarder )
0059 {
0060 BOOST_RANGE_CONCEPT_ASSERT((ForwardRangeConcept<const ForwardRng>));
0061 return uniqued_range<const ForwardRng>(r);
0062 }
0063
0064 }
0065
0066 using range_detail::uniqued_range;
0067
0068 namespace adaptors
0069 {
0070 namespace
0071 {
0072 const range_detail::unique_forwarder uniqued =
0073 range_detail::unique_forwarder();
0074 }
0075
0076 template<class ForwardRange>
0077 inline uniqued_range<ForwardRange>
0078 unique(ForwardRange& rng)
0079 {
0080 BOOST_RANGE_CONCEPT_ASSERT((ForwardRangeConcept<ForwardRange>));
0081 return uniqued_range<ForwardRange>(rng);
0082 }
0083
0084 template<class ForwardRange>
0085 inline uniqued_range<const ForwardRange>
0086 unique(const ForwardRange& rng)
0087 {
0088 BOOST_RANGE_CONCEPT_ASSERT((
0089 ForwardRangeConcept<const ForwardRange>));
0090
0091 return uniqued_range<const ForwardRange>(rng);
0092 }
0093 }
0094
0095 }
0096
0097 #endif