]> git.sesse.net Git - casparcg/blob - dependencies/boost/boost/range/counting_range.hpp
#297 Fixed support for flash templates with spaces in the file name.
[casparcg] / dependencies / boost / boost / range / counting_range.hpp
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)
5 //
6 //
7 // For more information, see http://www.boost.org/libs/range/
8 //
9 #ifndef BOOST_RANGE_COUNTING_RANGE_HPP_INCLUDED
10 #define BOOST_RANGE_COUNTING_RANGE_HPP_INCLUDED
11
12 #include <boost/config.hpp>
13 #if BOOST_MSVC >= 1400
14 #pragma warning(push)
15 #pragma warning(disable : 4244)
16 #endif
17
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>
22
23 namespace boost
24 {
25
26     template<class Value>
27     inline iterator_range<counting_iterator<Value> >
28     counting_range(Value first, Value last)
29     {
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));
34     }
35
36     template<class Range>
37     inline iterator_range<counting_iterator<BOOST_DEDUCED_TYPENAME range_value<const Range>::type> >
38     counting_range(const Range& rng)
39     {
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)
43             ? result_t()
44             : result_t(
45                 counting_iterator_t(*boost::begin(rng)),
46                 counting_iterator_t(*boost::prior(boost::end(rng))));
47     }
48
49     template<class Range>
50     inline iterator_range<counting_iterator<BOOST_DEDUCED_TYPENAME range_value<Range>::type> >
51     counting_range(Range& rng)
52     {
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)
56             ? result_t()
57             : result_t(
58                 counting_iterator_t(*boost::begin(rng)),
59                 counting_iterator_t(*boost::prior(boost::end(rng))));
60     }
61 } // namespace boost
62
63 #if BOOST_MSVC >= 1400
64 #pragma warning(pop)
65 #endif
66
67 #endif // include guard