Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:51:14

0001 // Boost.Range library
0002 //
0003 //  Copyright Thorsten Ottosen, Neil Groves 2006 - 2008. Use, modification and
0004 //  distribution is subject to the Boost Software License, Version
0005 //  1.0. (See accompanying file LICENSE_1_0.txt or copy at
0006 //  http://www.boost.org/LICENSE_1_0.txt)
0007 //
0008 // For more information, see http://www.boost.org/libs/range/
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     } // 'range_detail'
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     } // 'adaptors'
0094 
0095 }
0096 
0097 #endif