Chris@16: /* Chris@16: Copyright (c) Marshall Clow 2011-2012. Chris@16: Chris@16: Distributed under the Boost Software License, Version 1.0. (See accompanying Chris@16: file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) Chris@16: */ Chris@16: Chris@16: /// \file copy_n.hpp Chris@16: /// \brief Copy n items from one sequence to another Chris@16: /// \author Marshall Clow Chris@16: Chris@16: #ifndef BOOST_ALGORITHM_COPY_N_HPP Chris@16: #define BOOST_ALGORITHM_COPY_N_HPP Chris@16: Chris@16: #include // for std::copy_n, if available Chris@16: Chris@16: namespace boost { namespace algorithm { Chris@16: Chris@16: /// \fn copy_n ( InputIterator first, Size n, OutputIterator result ) Chris@16: /// \brief Copies exactly n (n > 0) elements from the range starting at first to Chris@16: /// the range starting at result. Chris@16: /// \return The updated output iterator Chris@16: /// Chris@16: /// \param first The start of the input sequence Chris@16: /// \param n The number of elements to copy Chris@16: /// \param result An output iterator to write the results into Chris@16: /// \note This function is part of the C++2011 standard library. Chris@16: /// We will use the standard one if it is available, Chris@16: /// otherwise we have our own implementation. Chris@16: template Chris@16: OutputIterator copy_n ( InputIterator first, Size n, OutputIterator result ) Chris@16: { Chris@16: for ( ; n > 0; --n, ++first, ++result ) Chris@16: *result = *first; Chris@16: return result; Chris@16: } Chris@16: }} // namespace boost and algorithm Chris@16: Chris@16: #endif // BOOST_ALGORITHM_COPY_IF_HPP