Chris@16
|
1 // Copyright Neil Groves 2010. Use, modification and
|
Chris@16
|
2 // distribution is subject to the Boost Software License, Version
|
Chris@16
|
3 // 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
Chris@16
|
4 // http://www.boost.org/LICENSE_1_0.txt)
|
Chris@16
|
5 //
|
Chris@16
|
6 //
|
Chris@16
|
7 // For more information, see http://www.boost.org/libs/range/
|
Chris@16
|
8 //
|
Chris@16
|
9 #ifndef BOOST_RANGE_COUNTING_RANGE_HPP_INCLUDED
|
Chris@16
|
10 #define BOOST_RANGE_COUNTING_RANGE_HPP_INCLUDED
|
Chris@16
|
11
|
Chris@16
|
12 #include <boost/config.hpp>
|
Chris@16
|
13 #if BOOST_MSVC >= 1400
|
Chris@16
|
14 #pragma warning(push)
|
Chris@16
|
15 #pragma warning(disable : 4244)
|
Chris@16
|
16 #endif
|
Chris@16
|
17
|
Chris@16
|
18 #include <boost/range/iterator_range_core.hpp>
|
Chris@16
|
19 #include <boost/range/value_type.hpp>
|
Chris@101
|
20 #include <boost/range/iterator.hpp>
|
Chris@16
|
21 #include <boost/iterator/counting_iterator.hpp>
|
Chris@16
|
22
|
Chris@16
|
23 namespace boost
|
Chris@16
|
24 {
|
Chris@16
|
25 template<class Value>
|
Chris@16
|
26 inline iterator_range<counting_iterator<Value> >
|
Chris@16
|
27 counting_range(Value first, Value last)
|
Chris@16
|
28 {
|
Chris@16
|
29 typedef counting_iterator<Value> counting_iterator_t;
|
Chris@16
|
30 typedef iterator_range<counting_iterator_t> result_t;
|
Chris@16
|
31 return result_t(counting_iterator_t(first),
|
Chris@16
|
32 counting_iterator_t(last));
|
Chris@16
|
33 }
|
Chris@16
|
34
|
Chris@16
|
35 template<class Range>
|
Chris@101
|
36 inline iterator_range<
|
Chris@101
|
37 counting_iterator<
|
Chris@101
|
38 BOOST_DEDUCED_TYPENAME range_iterator<const Range>::type
|
Chris@101
|
39 >
|
Chris@101
|
40 >
|
Chris@16
|
41 counting_range(const Range& rng)
|
Chris@16
|
42 {
|
Chris@101
|
43 typedef counting_iterator<
|
Chris@101
|
44 BOOST_DEDUCED_TYPENAME range_iterator<const Range>::type
|
Chris@101
|
45 > counting_iterator_t;
|
Chris@101
|
46
|
Chris@16
|
47 typedef iterator_range<counting_iterator_t> result_t;
|
Chris@101
|
48
|
Chris@101
|
49 return result_t(counting_iterator_t(boost::begin(rng)),
|
Chris@101
|
50 counting_iterator_t(boost::end(rng)));
|
Chris@16
|
51 }
|
Chris@16
|
52
|
Chris@16
|
53 template<class Range>
|
Chris@101
|
54 inline iterator_range<
|
Chris@101
|
55 counting_iterator<
|
Chris@101
|
56 BOOST_DEDUCED_TYPENAME range_iterator<Range>::type
|
Chris@101
|
57 >
|
Chris@101
|
58 >
|
Chris@16
|
59 counting_range(Range& rng)
|
Chris@16
|
60 {
|
Chris@101
|
61 typedef counting_iterator<
|
Chris@101
|
62 BOOST_DEDUCED_TYPENAME range_iterator<Range>::type
|
Chris@101
|
63 > counting_iterator_t;
|
Chris@101
|
64
|
Chris@16
|
65 typedef iterator_range<counting_iterator_t> result_t;
|
Chris@101
|
66
|
Chris@101
|
67 return result_t(counting_iterator_t(boost::begin(rng)),
|
Chris@101
|
68 counting_iterator_t(boost::end(rng)));
|
Chris@16
|
69 }
|
Chris@16
|
70 } // namespace boost
|
Chris@16
|
71
|
Chris@16
|
72 #if BOOST_MSVC >= 1400
|
Chris@16
|
73 #pragma warning(pop)
|
Chris@16
|
74 #endif
|
Chris@16
|
75
|
Chris@16
|
76 #endif // include guard
|