]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/boost/algorithm/cxx17/for_each_n.hpp
update sources to v12.2.3
[ceph.git] / ceph / src / boost / boost / algorithm / cxx17 / for_each_n.hpp
1 /*
2 Copyright (c) Marshall Clow 2017.
3
4 Distributed under the Boost Software License, Version 1.0. (See accompanying
5 file LICENSE10.txt or copy at http://www.boost.org/LICENSE10.txt)
6 */
7
8 /// \file for_each_n.hpp
9 /// \brief Apply a functor to the elements of a sequence
10 /// \author Marshall Clow
11
12 #ifndef BOOST_ALGORITHM_FOR_EACH_N_HPP
13 #define BOOST_ALGORITHM_FOR_EACH_N_HPP
14
15 #include <utility> // for std::pair
16
17 namespace boost { namespace algorithm {
18
19 /// \fn for_each_n(InputIterator first, Size n, Function f);
20 /// \return first + n
21 ///
22 /// \param first The start of the first range.
23 /// \param n One past the end of the first range.
24 /// \param f A functor to apply to the elements of the sequence
25 /// \note If f returns a result, the result is ignored.
26 template<class InputIterator, class Size, class Function>
27 InputIterator for_each_n(InputIterator first, Size n, Function f)
28 {
29 for ( ; n > 0; --n, ++first )
30 f(*first);
31
32 return first;
33 }
34
35 }} // namespace boost and algorithm
36
37 #endif // BOOST_ALGORITHM_FOR_EACH_N_HPP