Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:51:15

0001 //  Copyright Neil Groves 2009. Use, modification and
0002 //  distribution is subject to the Boost Software License, Version
0003 //  1.0. (See accompanying file LICENSE_1_0.txt or copy at
0004 //  http://www.boost.org/LICENSE_1_0.txt)
0005 //
0006 //
0007 // For more information, see http://www.boost.org/libs/range/
0008 //
0009 #ifndef BOOST_RANGE_ALGORITHM_COPY_N_HPP_INCLUDED
0010 #define BOOST_RANGE_ALGORITHM_COPY_N_HPP_INCLUDED
0011 
0012 #include <boost/assert.hpp>
0013 #include <boost/concept_check.hpp>
0014 #include <boost/range/begin.hpp>
0015 #include <boost/range/end.hpp>
0016 #include <boost/range/concepts.hpp>
0017 #include <boost/range/distance.hpp>
0018 #include <boost/range/iterator.hpp>
0019 #include <boost/range/iterator_range.hpp>
0020 #include <algorithm>
0021 
0022 namespace boost
0023 {
0024     namespace range
0025     {
0026 
0027 /// \brief template function copy
0028 ///
0029 /// range-based version of the copy std algorithm
0030 ///
0031 /// \pre SinglePassRange is a model of the SinglePassRangeConcept
0032 /// \pre OutputIterator is a model of the OutputIteratorConcept
0033 /// \pre 0 <= n <= distance(rng)
0034 template< class SinglePassRange, class Size, class OutputIterator >
0035 inline OutputIterator copy_n(const SinglePassRange& rng, Size n, OutputIterator out)
0036 {
0037     BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept<const SinglePassRange> ));
0038     BOOST_ASSERT( n <= static_cast<Size>(::boost::distance(rng)) );
0039     BOOST_ASSERT( n >= static_cast<Size>(0) );
0040 
0041     BOOST_DEDUCED_TYPENAME range_iterator<const SinglePassRange>::type source = ::boost::begin(rng);
0042 
0043     for (Size i = 0; i < n; ++i, ++out, ++source)
0044         *out = *source;
0045 
0046     return out;
0047 }
0048 
0049     } // namespace range
0050     using ::boost::range::copy_n;
0051 } // namespace boost
0052 
0053 #endif // include guard