annotate DEPENDENCIES/generic/include/boost/range/algorithm_ext/copy_n.hpp @ 133:4acb5d8d80b6 tip

Don't fail environmental check if README.md exists (but .txt and no-suffix don't)
author Chris Cannam
date Tue, 30 Jul 2019 12:25:44 +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_COPY_N_HPP_INCLUDED
Chris@16 10 #define BOOST_RANGE_ALGORITHM_COPY_N_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/range/begin.hpp>
Chris@16 15 #include <boost/range/end.hpp>
Chris@16 16 #include <boost/range/concepts.hpp>
Chris@16 17 #include <boost/range/distance.hpp>
Chris@16 18 #include <boost/range/iterator.hpp>
Chris@16 19 #include <boost/range/iterator_range.hpp>
Chris@16 20 #include <algorithm>
Chris@16 21
Chris@16 22 namespace boost
Chris@16 23 {
Chris@16 24 namespace range
Chris@16 25 {
Chris@16 26
Chris@16 27 /// \brief template function copy
Chris@16 28 ///
Chris@16 29 /// range-based version of the copy std algorithm
Chris@16 30 ///
Chris@16 31 /// \pre SinglePassRange is a model of the SinglePassRangeConcept
Chris@16 32 /// \pre OutputIterator is a model of the OutputIteratorConcept
Chris@16 33 /// \pre 0 <= n <= distance(rng)
Chris@16 34 template< class SinglePassRange, class Size, class OutputIterator >
Chris@16 35 inline OutputIterator copy_n(const SinglePassRange& rng, Size n, OutputIterator out)
Chris@16 36 {
Chris@16 37 BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept<const SinglePassRange> ));
Chris@16 38 BOOST_ASSERT( n <= static_cast<Size>(::boost::distance(rng)) );
Chris@16 39 BOOST_ASSERT( n >= static_cast<Size>(0) );
Chris@16 40
Chris@16 41 BOOST_DEDUCED_TYPENAME range_iterator<const SinglePassRange>::type source = ::boost::begin(rng);
Chris@16 42
Chris@16 43 for (Size i = 0; i < n; ++i, ++out, ++source)
Chris@16 44 *out = *source;
Chris@16 45
Chris@16 46 return out;
Chris@16 47 }
Chris@16 48
Chris@16 49 } // namespace range
Chris@16 50 using ::boost::range::copy_n;
Chris@16 51 } // namespace boost
Chris@16 52
Chris@16 53 #endif // include guard