Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:28:23

0001 /*
0002    Copyright (c) Marshall Clow 2017.
0003 
0004    Distributed under the Boost Software License, Version 1.0. (See accompanying
0005    file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
0006 */
0007 
0008 /// \file  for_each_n.hpp
0009 /// \brief Apply a functor to the elements of a sequence
0010 /// \author Marshall Clow
0011 
0012 #ifndef BOOST_ALGORITHM_FOR_EACH_N_HPP
0013 #define BOOST_ALGORITHM_FOR_EACH_N_HPP
0014 
0015 #include <utility>      // for std::pair
0016 
0017 #include <boost/config.hpp>
0018 
0019 namespace boost { namespace algorithm {
0020 
0021 /// \fn for_each_n(InputIterator first, Size n, Function f);
0022 /// \return first + n
0023 ///
0024 /// \param first    The start of the first range.
0025 /// \param n        One past the end of the first range.
0026 /// \param f        A functor to apply to the elements of the sequence
0027 /// \note           If f returns a result, the result is ignored.
0028 template<class InputIterator, class Size, class Function>
0029 InputIterator for_each_n(InputIterator first, Size n, Function f)
0030 {
0031     for ( ; n > 0; --n, ++first )
0032         f(*first);
0033 
0034     return first;
0035 }
0036 
0037 }} // namespace boost and algorithm
0038 
0039 #endif // BOOST_ALGORITHM_FOR_EACH_N_HPP