annotate DEPENDENCIES/generic/include/boost/range/algorithm/swap_ranges.hpp @ 125:34e428693f5d vext

Vext -> Repoint
author Chris Cannam
date Thu, 14 Jun 2018 11:15:39 +0100
parents 2665513ce2d3
children
rev   line source
Chris@16 1 // Copyright Neil Groves 2009. 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_ALGORITHM_SWAP_RANGES_HPP_INCLUDED
Chris@16 10 #define BOOST_RANGE_ALGORITHM_SWAP_RANGES_HPP_INCLUDED
Chris@16 11
Chris@16 12 #include <boost/assert.hpp>
Chris@16 13 #include <boost/concept_check.hpp>
Chris@16 14 #include <boost/iterator/iterator_categories.hpp>
Chris@16 15 #include <boost/range/begin.hpp>
Chris@16 16 #include <boost/range/end.hpp>
Chris@16 17 #include <boost/range/concepts.hpp>
Chris@16 18 #include <boost/range/iterator.hpp>
Chris@16 19 #include <algorithm>
Chris@16 20
Chris@16 21 namespace boost
Chris@16 22 {
Chris@16 23 namespace range_detail
Chris@16 24 {
Chris@16 25 template<class Iterator1, class Iterator2>
Chris@16 26 void swap_ranges_impl(Iterator1 it1, Iterator1 last1,
Chris@16 27 Iterator2 it2, Iterator2 last2,
Chris@16 28 single_pass_traversal_tag,
Chris@16 29 single_pass_traversal_tag)
Chris@16 30 {
Chris@16 31 ignore_unused_variable_warning(last2);
Chris@16 32 for (; it1 != last1; ++it1, ++it2)
Chris@16 33 {
Chris@16 34 BOOST_ASSERT( it2 != last2 );
Chris@16 35 std::iter_swap(it1, it2);
Chris@16 36 }
Chris@16 37 }
Chris@16 38
Chris@16 39 template<class Iterator1, class Iterator2>
Chris@16 40 void swap_ranges_impl(Iterator1 it1, Iterator1 last1,
Chris@16 41 Iterator2 it2, Iterator2 last2,
Chris@16 42 random_access_traversal_tag,
Chris@16 43 random_access_traversal_tag)
Chris@16 44 {
Chris@16 45 ignore_unused_variable_warning(last2);
Chris@16 46 BOOST_ASSERT( last2 - it2 >= last1 - it1 );
Chris@16 47 std::swap_ranges(it1, last1, it2);
Chris@16 48 }
Chris@16 49
Chris@16 50 template<class Iterator1, class Iterator2>
Chris@16 51 void swap_ranges_impl(Iterator1 first1, Iterator1 last1,
Chris@16 52 Iterator2 first2, Iterator2 last2)
Chris@16 53 {
Chris@16 54 swap_ranges_impl(first1, last1, first2, last2,
Chris@16 55 BOOST_DEDUCED_TYPENAME iterator_traversal<Iterator1>::type(),
Chris@16 56 BOOST_DEDUCED_TYPENAME iterator_traversal<Iterator2>::type());
Chris@16 57 }
Chris@16 58 } // namespace range_detail
Chris@16 59
Chris@16 60 namespace range
Chris@16 61 {
Chris@16 62
Chris@16 63 /// \brief template function swap_ranges
Chris@16 64 ///
Chris@16 65 /// range-based version of the swap_ranges std algorithm
Chris@16 66 ///
Chris@16 67 /// \pre SinglePassRange1 is a model of the SinglePassRangeConcept
Chris@16 68 /// \pre SinglePassRange2 is a model of the SinglePassRangeConcept
Chris@16 69 template< class SinglePassRange1, class SinglePassRange2 >
Chris@16 70 inline SinglePassRange2&
Chris@16 71 swap_ranges(SinglePassRange1& range1, SinglePassRange2& range2)
Chris@16 72 {
Chris@16 73 BOOST_RANGE_CONCEPT_ASSERT((SinglePassRangeConcept<SinglePassRange1>));
Chris@16 74 BOOST_RANGE_CONCEPT_ASSERT((SinglePassRangeConcept<SinglePassRange2>));
Chris@16 75
Chris@16 76 boost::range_detail::swap_ranges_impl(
Chris@16 77 boost::begin(range1), boost::end(range1),
Chris@16 78 boost::begin(range2), boost::end(range2));
Chris@16 79
Chris@16 80 return range2;
Chris@16 81 }
Chris@16 82
Chris@16 83 /// \overload
Chris@16 84 template< class SinglePassRange1, class SinglePassRange2 >
Chris@16 85 inline SinglePassRange2&
Chris@16 86 swap_ranges(const SinglePassRange1& range1, SinglePassRange2& range2)
Chris@16 87 {
Chris@16 88 BOOST_RANGE_CONCEPT_ASSERT((SinglePassRangeConcept<const SinglePassRange1>));
Chris@16 89 BOOST_RANGE_CONCEPT_ASSERT((SinglePassRangeConcept<SinglePassRange2>));
Chris@16 90
Chris@16 91 boost::range_detail::swap_ranges_impl(
Chris@16 92 boost::begin(range1), boost::end(range1),
Chris@16 93 boost::begin(range2), boost::end(range2));
Chris@16 94
Chris@16 95 return range2;
Chris@16 96 }
Chris@16 97
Chris@16 98 /// \overload
Chris@16 99 template< class SinglePassRange1, class SinglePassRange2 >
Chris@16 100 inline const SinglePassRange2&
Chris@16 101 swap_ranges(SinglePassRange1& range1, const SinglePassRange2& range2)
Chris@16 102 {
Chris@16 103 BOOST_RANGE_CONCEPT_ASSERT((SinglePassRangeConcept<SinglePassRange1>));
Chris@16 104 BOOST_RANGE_CONCEPT_ASSERT((SinglePassRangeConcept<const SinglePassRange2>));
Chris@16 105
Chris@16 106 boost::range_detail::swap_ranges_impl(
Chris@16 107 boost::begin(range1), boost::end(range1),
Chris@16 108 boost::begin(range2), boost::end(range2));
Chris@16 109
Chris@16 110 return range2;
Chris@16 111 }
Chris@16 112
Chris@16 113 /// \overload
Chris@16 114 template< class SinglePassRange1, class SinglePassRange2 >
Chris@16 115 inline const SinglePassRange2&
Chris@16 116 swap_ranges(const SinglePassRange1& range1, const SinglePassRange2& range2)
Chris@16 117 {
Chris@16 118 BOOST_RANGE_CONCEPT_ASSERT((SinglePassRangeConcept<const SinglePassRange1>));
Chris@16 119 BOOST_RANGE_CONCEPT_ASSERT((SinglePassRangeConcept<const SinglePassRange2>));
Chris@16 120
Chris@16 121 boost::range_detail::swap_ranges_impl(
Chris@16 122 boost::begin(range1), boost::end(range1),
Chris@16 123 boost::begin(range2), boost::end(range2));
Chris@16 124
Chris@16 125 return range2;
Chris@16 126 }
Chris@16 127
Chris@16 128 } // namespace range
Chris@16 129 using range::swap_ranges;
Chris@16 130 } // namespace boost
Chris@16 131
Chris@16 132 #endif // include guard