Chris@16: // Copyright Neil Groves 2009. Use, modification and Chris@16: // distribution is subject to the Boost Software License, Version Chris@16: // 1.0. (See accompanying file LICENSE_1_0.txt or copy at Chris@16: // http://www.boost.org/LICENSE_1_0.txt) Chris@16: // Chris@16: // Chris@16: // For more information, see http://www.boost.org/libs/range/ Chris@16: // Chris@16: #ifndef BOOST_RANGE_ALGORITHM_COPY_N_HPP_INCLUDED Chris@16: #define BOOST_RANGE_ALGORITHM_COPY_N_HPP_INCLUDED Chris@16: Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: Chris@16: namespace boost Chris@16: { Chris@16: namespace range Chris@16: { Chris@16: Chris@16: /// \brief template function copy Chris@16: /// Chris@16: /// range-based version of the copy std algorithm Chris@16: /// Chris@16: /// \pre SinglePassRange is a model of the SinglePassRangeConcept Chris@16: /// \pre OutputIterator is a model of the OutputIteratorConcept Chris@16: /// \pre 0 <= n <= distance(rng) Chris@16: template< class SinglePassRange, class Size, class OutputIterator > Chris@16: inline OutputIterator copy_n(const SinglePassRange& rng, Size n, OutputIterator out) Chris@16: { Chris@16: BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept )); Chris@16: BOOST_ASSERT( n <= static_cast(::boost::distance(rng)) ); Chris@16: BOOST_ASSERT( n >= static_cast(0) ); Chris@16: Chris@16: BOOST_DEDUCED_TYPENAME range_iterator::type source = ::boost::begin(rng); Chris@16: Chris@16: for (Size i = 0; i < n; ++i, ++out, ++source) Chris@16: *out = *source; Chris@16: Chris@16: return out; Chris@16: } Chris@16: Chris@16: } // namespace range Chris@16: using ::boost::range::copy_n; Chris@16: } // namespace boost Chris@16: Chris@16: #endif // include guard