Chris@16
|
1 // Boost.Range library
|
Chris@16
|
2 //
|
Chris@16
|
3 // Copyright Thorsten Ottosen, Neil Groves 2006 - 2008. Use, modification and
|
Chris@16
|
4 // distribution is subject to the Boost Software License, Version
|
Chris@16
|
5 // 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
Chris@16
|
6 // http://www.boost.org/LICENSE_1_0.txt)
|
Chris@16
|
7 //
|
Chris@16
|
8 // For more information, see http://www.boost.org/libs/range/
|
Chris@16
|
9 //
|
Chris@16
|
10
|
Chris@16
|
11 #ifndef BOOST_RANGE_ADAPTOR_INDIRECTED_HPP
|
Chris@16
|
12 #define BOOST_RANGE_ADAPTOR_INDIRECTED_HPP
|
Chris@16
|
13
|
Chris@16
|
14 #include <boost/range/iterator_range.hpp>
|
Chris@16
|
15 #include <boost/iterator/indirect_iterator.hpp>
|
Chris@16
|
16
|
Chris@16
|
17 namespace boost
|
Chris@16
|
18 {
|
Chris@16
|
19 namespace range_detail
|
Chris@16
|
20 {
|
Chris@16
|
21 template< class R >
|
Chris@16
|
22 struct indirected_range :
|
Chris@16
|
23 public boost::iterator_range<
|
Chris@16
|
24 boost::indirect_iterator<
|
Chris@16
|
25 BOOST_DEDUCED_TYPENAME range_iterator<R>::type
|
Chris@16
|
26 >
|
Chris@16
|
27 >
|
Chris@16
|
28 {
|
Chris@16
|
29 private:
|
Chris@16
|
30 typedef boost::iterator_range<
|
Chris@16
|
31 boost::indirect_iterator<
|
Chris@16
|
32 BOOST_DEDUCED_TYPENAME range_iterator<R>::type
|
Chris@16
|
33 >
|
Chris@16
|
34 >
|
Chris@16
|
35 base;
|
Chris@16
|
36
|
Chris@16
|
37 public:
|
Chris@16
|
38 explicit indirected_range( R& r )
|
Chris@16
|
39 : base( r )
|
Chris@16
|
40 { }
|
Chris@16
|
41 };
|
Chris@16
|
42
|
Chris@16
|
43 struct indirect_forwarder {};
|
Chris@16
|
44
|
Chris@16
|
45 template< class InputRng >
|
Chris@16
|
46 inline indirected_range<InputRng>
|
Chris@16
|
47 operator|( InputRng& r, indirect_forwarder )
|
Chris@16
|
48 {
|
Chris@16
|
49 return indirected_range<InputRng>( r );
|
Chris@16
|
50 }
|
Chris@16
|
51
|
Chris@16
|
52 template< class InputRng >
|
Chris@16
|
53 inline indirected_range<const InputRng>
|
Chris@16
|
54 operator|( const InputRng& r, indirect_forwarder )
|
Chris@16
|
55 {
|
Chris@16
|
56 return indirected_range<const InputRng>( r );
|
Chris@16
|
57 }
|
Chris@16
|
58
|
Chris@16
|
59 } // 'range_detail'
|
Chris@16
|
60
|
Chris@16
|
61 using range_detail::indirected_range;
|
Chris@16
|
62
|
Chris@16
|
63 namespace adaptors
|
Chris@16
|
64 {
|
Chris@16
|
65 namespace
|
Chris@16
|
66 {
|
Chris@16
|
67 const range_detail::indirect_forwarder indirected =
|
Chris@16
|
68 range_detail::indirect_forwarder();
|
Chris@16
|
69 }
|
Chris@16
|
70
|
Chris@16
|
71 template<class InputRange>
|
Chris@16
|
72 inline indirected_range<InputRange>
|
Chris@16
|
73 indirect(InputRange& rng)
|
Chris@16
|
74 {
|
Chris@16
|
75 return indirected_range<InputRange>(rng);
|
Chris@16
|
76 }
|
Chris@16
|
77
|
Chris@16
|
78 template<class InputRange>
|
Chris@16
|
79 inline indirected_range<const InputRange>
|
Chris@16
|
80 indirect(const InputRange& rng)
|
Chris@16
|
81 {
|
Chris@16
|
82 return indirected_range<const InputRange>(rng);
|
Chris@16
|
83 }
|
Chris@16
|
84 } // 'adaptors'
|
Chris@16
|
85
|
Chris@16
|
86 }
|
Chris@16
|
87
|
Chris@16
|
88 #endif
|