comparison DEPENDENCIES/generic/include/boost/range/adaptor/reversed.hpp @ 16:2665513ce2d3

Add boost headers
author Chris Cannam
date Tue, 05 Aug 2014 11:11:38 +0100
parents
children c530137014c0
comparison
equal deleted inserted replaced
15:663ca0da4350 16:2665513ce2d3
1 // Boost.Range library
2 //
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)
7 //
8 // For more information, see http://www.boost.org/libs/range/
9 //
10
11 #ifndef BOOST_RANGE_ADAPTOR_REVERSED_HPP
12 #define BOOST_RANGE_ADAPTOR_REVERSED_HPP
13
14 #include <boost/range/iterator_range.hpp>
15 #include <boost/iterator/reverse_iterator.hpp>
16
17 namespace boost
18 {
19 namespace range_detail
20 {
21 template< class R >
22 struct reversed_range :
23 public boost::iterator_range<
24 boost::reverse_iterator<
25 BOOST_DEDUCED_TYPENAME range_iterator<R>::type
26 >
27 >
28 {
29 private:
30 typedef boost::iterator_range<
31 boost::reverse_iterator<
32 BOOST_DEDUCED_TYPENAME range_iterator<R>::type
33 >
34 >
35 base;
36
37 public:
38 typedef boost::reverse_iterator<BOOST_DEDUCED_TYPENAME range_iterator<R>::type> iterator;
39
40 explicit reversed_range( R& r )
41 : base( iterator(boost::end(r)), iterator(boost::begin(r)) )
42 { }
43 };
44
45 struct reverse_forwarder {};
46
47 template< class BidirectionalRng >
48 inline reversed_range<BidirectionalRng>
49 operator|( BidirectionalRng& r, reverse_forwarder )
50 {
51 return reversed_range<BidirectionalRng>( r );
52 }
53
54 template< class BidirectionalRng >
55 inline reversed_range<const BidirectionalRng>
56 operator|( const BidirectionalRng& r, reverse_forwarder )
57 {
58 return reversed_range<const BidirectionalRng>( r );
59 }
60
61 } // 'range_detail'
62
63 using range_detail::reversed_range;
64
65 namespace adaptors
66 {
67 namespace
68 {
69 const range_detail::reverse_forwarder reversed =
70 range_detail::reverse_forwarder();
71 }
72
73 template<class BidirectionalRange>
74 inline reversed_range<BidirectionalRange>
75 reverse(BidirectionalRange& rng)
76 {
77 return reversed_range<BidirectionalRange>(rng);
78 }
79
80 template<class BidirectionalRange>
81 inline reversed_range<const BidirectionalRange>
82 reverse(const BidirectionalRange& rng)
83 {
84 return reversed_range<const BidirectionalRange>(rng);
85 }
86 } // 'adaptors'
87
88 } // 'boost'
89
90 #endif