1 // Copyright Neil Groves 2010. Use, modification and
2 // distribution is subject to the Boost Software License, Version
3 // 1.0. (See accompanying file LICENSE_1_0.txt or copy at
4 // http://www.boost.org/LICENSE_1_0.txt)
7 // For more information, see http://www.boost.org/libs/range/
9 #ifndef BOOST_RANGE_COUNTING_RANGE_HPP_INCLUDED
10 #define BOOST_RANGE_COUNTING_RANGE_HPP_INCLUDED
12 #include <boost/config.hpp>
13 #if BOOST_MSVC >= 1400
15 #pragma warning(disable : 4244)
18 #include <boost/range/iterator_range_core.hpp>
19 #include <boost/range/value_type.hpp>
20 #include <boost/iterator/counting_iterator.hpp>
21 #include <boost/utility.hpp>
27 inline iterator_range<counting_iterator<Value> >
28 counting_range(Value first, Value last)
30 typedef counting_iterator<Value> counting_iterator_t;
31 typedef iterator_range<counting_iterator_t> result_t;
32 return result_t(counting_iterator_t(first),
33 counting_iterator_t(last));
37 inline iterator_range<counting_iterator<BOOST_DEDUCED_TYPENAME range_value<const Range>::type> >
38 counting_range(const Range& rng)
40 typedef counting_iterator<BOOST_DEDUCED_TYPENAME range_value<const Range>::type> counting_iterator_t;
41 typedef iterator_range<counting_iterator_t> result_t;
42 return boost::empty(rng)
45 counting_iterator_t(*boost::begin(rng)),
46 counting_iterator_t(*boost::prior(boost::end(rng))));
50 inline iterator_range<counting_iterator<BOOST_DEDUCED_TYPENAME range_value<Range>::type> >
51 counting_range(Range& rng)
53 typedef counting_iterator<BOOST_DEDUCED_TYPENAME range_value<Range>::type> counting_iterator_t;
54 typedef iterator_range<counting_iterator_t> result_t;
55 return boost::empty(rng)
58 counting_iterator_t(*boost::begin(rng)),
59 counting_iterator_t(*boost::prior(boost::end(rng))));
63 #if BOOST_MSVC >= 1400
67 #endif // include guard