Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-12-16 10:08:18

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_REVERSED_HPP
0012 #define BOOST_RANGE_ADAPTOR_REVERSED_HPP
0013 
0014 #include <boost/range/iterator_range.hpp>
0015 #include <boost/range/concepts.hpp>
0016 #include <boost/iterator/reverse_iterator.hpp>
0017 
0018 namespace boost
0019 {
0020     namespace range_detail
0021     {
0022         template< class R >
0023         struct reversed_range : 
0024             public boost::iterator_range< 
0025                       boost::reverse_iterator<
0026                         BOOST_DEDUCED_TYPENAME range_iterator<R>::type 
0027                                               >
0028                                          >
0029         {
0030         private:
0031             typedef boost::iterator_range< 
0032                       boost::reverse_iterator<
0033                         BOOST_DEDUCED_TYPENAME range_iterator<R>::type 
0034                                               >
0035                                          >
0036                 base;
0037             
0038         public:
0039             typedef boost::reverse_iterator<BOOST_DEDUCED_TYPENAME range_iterator<R>::type> iterator;
0040 
0041             explicit reversed_range( R& r ) 
0042                 : base( iterator(boost::end(r)), iterator(boost::begin(r)) )
0043             { }
0044         };
0045 
0046         struct reverse_forwarder {};
0047         
0048         template< class BidirectionalRange >
0049         inline reversed_range<BidirectionalRange> 
0050         operator|( BidirectionalRange& r, reverse_forwarder )
0051         {
0052             BOOST_RANGE_CONCEPT_ASSERT((
0053                 BidirectionalRangeConcept<BidirectionalRange>));
0054 
0055             return reversed_range<BidirectionalRange>( r );
0056         }
0057 
0058         template< class BidirectionalRange >
0059         inline reversed_range<const BidirectionalRange> 
0060         operator|( const BidirectionalRange& r, reverse_forwarder )
0061         {
0062             BOOST_RANGE_CONCEPT_ASSERT((
0063                 BidirectionalRangeConcept<const BidirectionalRange>));
0064 
0065             return reversed_range<const BidirectionalRange>( r ); 
0066         }
0067         
0068     } // 'range_detail'
0069     
0070     using range_detail::reversed_range;
0071 
0072     namespace adaptors
0073     { 
0074         namespace
0075         {
0076             const range_detail::reverse_forwarder reversed = 
0077                                             range_detail::reverse_forwarder();
0078         }
0079         
0080         template<class BidirectionalRange>
0081         inline reversed_range<BidirectionalRange>
0082         reverse(BidirectionalRange& rng)
0083         {
0084             BOOST_RANGE_CONCEPT_ASSERT((
0085                 BidirectionalRangeConcept<BidirectionalRange>));
0086 
0087             return reversed_range<BidirectionalRange>(rng);
0088         }
0089         
0090         template<class BidirectionalRange>
0091         inline reversed_range<const BidirectionalRange>
0092         reverse(const BidirectionalRange& rng)
0093         {
0094             BOOST_RANGE_CONCEPT_ASSERT((
0095                 BidirectionalRangeConcept<const BidirectionalRange>));
0096 
0097             return reversed_range<const BidirectionalRange>(rng);
0098         }
0099     } // 'adaptors'
0100     
0101 } // 'boost'
0102 
0103 #endif