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_INDIRECTED_HPP |
---|
12 | #define BOOST_RANGE_ADAPTOR_INDIRECTED_HPP |
---|
13 | |
---|
14 | #include <boost/range/iterator_range.hpp> |
---|
15 | #include <boost/iterator/indirect_iterator.hpp> |
---|
16 | |
---|
17 | namespace boost |
---|
18 | { |
---|
19 | namespace range_detail |
---|
20 | { |
---|
21 | template< class R > |
---|
22 | struct indirect_range : |
---|
23 | public boost::iterator_range< |
---|
24 | boost::indirect_iterator< |
---|
25 | BOOST_DEDUCED_TYPENAME range_iterator<R>::type |
---|
26 | > |
---|
27 | > |
---|
28 | { |
---|
29 | private: |
---|
30 | typedef boost::iterator_range< |
---|
31 | boost::indirect_iterator< |
---|
32 | BOOST_DEDUCED_TYPENAME range_iterator<R>::type |
---|
33 | > |
---|
34 | > |
---|
35 | base; |
---|
36 | |
---|
37 | public: |
---|
38 | explicit indirect_range( R& r ) |
---|
39 | : base( r ) |
---|
40 | { } |
---|
41 | }; |
---|
42 | |
---|
43 | struct indirect_forwarder {}; |
---|
44 | |
---|
45 | template< class InputRng > |
---|
46 | inline indirect_range<InputRng> |
---|
47 | operator|( InputRng& r, indirect_forwarder ) |
---|
48 | { |
---|
49 | return indirect_range<InputRng>( r ); |
---|
50 | } |
---|
51 | |
---|
52 | template< class InputRng > |
---|
53 | inline indirect_range<const InputRng> |
---|
54 | operator|( const InputRng& r, indirect_forwarder ) |
---|
55 | { |
---|
56 | return indirect_range<const InputRng>( r ); |
---|
57 | } |
---|
58 | |
---|
59 | } // 'range_detail' |
---|
60 | |
---|
61 | using range_detail::indirect_range; |
---|
62 | |
---|
63 | namespace adaptors |
---|
64 | { |
---|
65 | namespace |
---|
66 | { |
---|
67 | const range_detail::indirect_forwarder indirected = |
---|
68 | range_detail::indirect_forwarder(); |
---|
69 | } |
---|
70 | |
---|
71 | template<class InputRange> |
---|
72 | inline indirect_range<InputRange> |
---|
73 | indirect(InputRange& rng) |
---|
74 | { |
---|
75 | return indirect_range<InputRange>(rng); |
---|
76 | } |
---|
77 | |
---|
78 | template<class InputRange> |
---|
79 | inline indirect_range<const InputRange> |
---|
80 | indirect(const InputRange& rng) |
---|
81 | { |
---|
82 | return indirect_range<const InputRange>(rng); |
---|
83 | } |
---|
84 | } // 'adaptors' |
---|
85 | |
---|
86 | } |
---|
87 | |
---|
88 | #endif |
---|