]>
Commit | Line | Data |
---|---|---|
1 | //---------------------------------------------------------------------------// | |
2 | // Copyright (c) 2013-2014 Kyle Lutz <kyle.r.lutz@gmail.com> | |
3 | // | |
4 | // Distributed under the Boost Software License, Version 1.0 | |
5 | // See accompanying file LICENSE_1_0.txt or copy at | |
6 | // http://www.boost.org/LICENSE_1_0.txt | |
7 | // | |
8 | // See http://boostorg.github.com/compute for more information. | |
9 | //---------------------------------------------------------------------------// | |
10 | ||
11 | #ifndef BOOST_COMPUTE_ALGORITHM_FOR_EACH_N_HPP | |
12 | #define BOOST_COMPUTE_ALGORITHM_FOR_EACH_N_HPP | |
13 | ||
14 | #include <boost/static_assert.hpp> | |
15 | ||
16 | #include <boost/compute/algorithm/for_each.hpp> | |
17 | #include <boost/compute/type_traits/is_device_iterator.hpp> | |
18 | ||
19 | namespace boost { | |
20 | namespace compute { | |
21 | ||
22 | /// Calls \p function on each element in the range [\p first, \p first | |
23 | /// \c + \p count). | |
24 | /// | |
25 | /// Space complexity: \Omega(1) | |
26 | /// | |
27 | /// \see for_each() | |
28 | template<class InputIterator, class Size, class UnaryFunction> | |
29 | inline UnaryFunction for_each_n(InputIterator first, | |
30 | Size count, | |
31 | UnaryFunction function, | |
32 | command_queue &queue = system::default_queue()) | |
33 | { | |
34 | BOOST_STATIC_ASSERT(is_device_iterator<InputIterator>::value); | |
35 | return ::boost::compute::for_each(first, first + count, function, queue); | |
36 | } | |
37 | ||
38 | } // end compute namespace | |
39 | } // end boost namespace | |
40 | ||
41 | #endif // BOOST_COMPUTE_ALGORITHM_FOR_EACH_N_HPP |