]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/boost/compute/algorithm/generate.hpp
update sources to v12.2.3
[ceph.git] / ceph / src / boost / boost / compute / algorithm / generate.hpp
1 //---------------------------------------------------------------------------//
2 // Copyright (c) 2013 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_GENERATE_HPP
12 #define BOOST_COMPUTE_ALGORITHM_GENERATE_HPP
13
14 #include <boost/compute/system.hpp>
15 #include <boost/compute/command_queue.hpp>
16 #include <boost/compute/algorithm/copy.hpp>
17 #include <boost/compute/iterator/function_input_iterator.hpp>
18 #include <boost/compute/detail/iterator_range_size.hpp>
19
20 namespace boost {
21 namespace compute {
22
23 /// Stores the result of \p generator for each element in the range
24 /// [\p first, \p last).
25 ///
26 /// Space complexity: \Omega(1)
27 template<class OutputIterator, class Generator>
28 inline void generate(OutputIterator first,
29 OutputIterator last,
30 Generator generator,
31 command_queue &queue = system::default_queue())
32 {
33 size_t count = detail::iterator_range_size(first, last);
34 if(count == 0){
35 return;
36 }
37
38 ::boost::compute::copy(
39 ::boost::compute::make_function_input_iterator(generator,
40 first.get_index()),
41 ::boost::compute::make_function_input_iterator(generator,
42 last.get_index()),
43 first,
44 queue
45 );
46 }
47
48 } // end compute namespace
49 } // end boost namespace
50
51 #endif // BOOST_COMPUTE_ALGORITHM_GENERATE_HPP