2 Copyright (c) Marshall Clow 2017.
4 Distributed under the Boost Software License, Version 1.0. (See accompanying
5 file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
8 /// \file for_each_n.hpp
9 /// \brief Apply a functor to the elements of a sequence
10 /// \author Marshall Clow
12 #ifndef BOOST_ALGORITHM_FOR_EACH_N_HPP
13 #define BOOST_ALGORITHM_FOR_EACH_N_HPP
15 #include <utility> // for std::pair
17 #include <boost/config.hpp>
19 namespace boost { namespace algorithm {
21 /// \fn for_each_n(InputIterator first, Size n, Function f);
24 /// \param first The start of the first range.
25 /// \param n One past the end of the first range.
26 /// \param f A functor to apply to the elements of the sequence
27 /// \note If f returns a result, the result is ignored.
28 template<class InputIterator, class Size, class Function>
29 InputIterator for_each_n(InputIterator first, Size n, Function f)
31 for ( ; n > 0; --n, ++first )
37 }} // namespace boost and algorithm
39 #endif // BOOST_ALGORITHM_FOR_EACH_N_HPP