1 | // Copyright Neil Groves 2009. 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_ALGORITHM_REVERSE_HPP_INCLUDED |
---|
10 | #define BOOST_RANGE_ALGORITHM_REVERSE_HPP_INCLUDED |
---|
11 | |
---|
12 | #include <boost/concept_check.hpp> |
---|
13 | #include <boost/range/begin.hpp> |
---|
14 | #include <boost/range/end.hpp> |
---|
15 | #include <boost/range/concepts.hpp> |
---|
16 | #include <boost/range/detail/range_return.hpp> |
---|
17 | #include <algorithm> |
---|
18 | |
---|
19 | namespace boost |
---|
20 | { |
---|
21 | namespace range |
---|
22 | { |
---|
23 | |
---|
24 | /// \brief template function reverse |
---|
25 | /// |
---|
26 | /// range-based version of the reverse std algorithm |
---|
27 | /// |
---|
28 | /// \pre BidirectionalRange is a model of the BidirectionalRangeConcept |
---|
29 | template<class BidirectionalRange> |
---|
30 | inline BidirectionalRange& reverse(BidirectionalRange& rng) |
---|
31 | { |
---|
32 | BOOST_RANGE_CONCEPT_ASSERT(( BidirectionalRangeConcept<BidirectionalRange> )); |
---|
33 | std::reverse(boost::begin(rng), boost::end(rng)); |
---|
34 | return rng; |
---|
35 | } |
---|
36 | |
---|
37 | /// \overload |
---|
38 | template<class BidirectionalRange> |
---|
39 | inline const BidirectionalRange& reverse(const BidirectionalRange& rng) |
---|
40 | { |
---|
41 | BOOST_RANGE_CONCEPT_ASSERT(( BidirectionalRangeConcept<const BidirectionalRange> )); |
---|
42 | std::reverse(boost::begin(rng), boost::end(rng)); |
---|
43 | return rng; |
---|
44 | } |
---|
45 | |
---|
46 | } // namespace range |
---|
47 | using range::reverse; |
---|
48 | } // namespace boost |
---|
49 | |
---|
50 | #endif // include guard |
---|