]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/boost/compute/algorithm/iota.hpp
update sources to v12.2.3
[ceph.git] / ceph / src / boost / boost / compute / algorithm / iota.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_IOTA_HPP
12 #define BOOST_COMPUTE_ALGORITHM_IOTA_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/counting_iterator.hpp>
18
19 namespace boost {
20 namespace compute {
21
22 /// Fills the range [\p first, \p last) with sequential values starting at
23 /// \p value.
24 ///
25 /// For example, the following code:
26 /// \snippet test/test_iota.cpp iota
27 ///
28 /// Will fill \c vec with the values (\c 0, \c 1, \c 2, \c ...).
29 ///
30 /// Space complexity: \Omega(1)
31 template<class BufferIterator, class T>
32 inline void iota(BufferIterator first,
33 BufferIterator last,
34 const T &value,
35 command_queue &queue = system::default_queue())
36 {
37 T count = static_cast<T>(detail::iterator_range_size(first, last));
38
39 copy(
40 ::boost::compute::make_counting_iterator(value),
41 ::boost::compute::make_counting_iterator(value + count),
42 first,
43 queue
44 );
45 }
46
47 } // end compute namespace
48 } // end boost namespace
49
50 #endif // BOOST_COMPUTE_ALGORITHM_IOTA_HPP