]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/boost/compute/algorithm/copy_n.hpp
update sources to v12.2.3
[ceph.git] / ceph / src / boost / boost / compute / algorithm / copy_n.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_COPY_N_HPP
12 #define BOOST_COMPUTE_ALGORITHM_COPY_N_HPP
13
14 #include <boost/compute/system.hpp>
15 #include <boost/compute/command_queue.hpp>
16 #include <boost/compute/algorithm/copy.hpp>
17
18 namespace boost {
19 namespace compute {
20
21 /// Copies \p count elements from \p first to \p result.
22 ///
23 /// For example, to copy four values from the host to the device:
24 /// \code
25 /// // values on the host and vector on the device
26 /// float values[4] = { 1.f, 2.f, 3.f, 4.f };
27 /// boost::compute::vector<float> vec(4, context);
28 ///
29 /// // copy from the host to the device
30 /// boost::compute::copy_n(values, 4, vec.begin(), queue);
31 /// \endcode
32 ///
33 /// Space complexity: \Omega(1)
34 ///
35 /// \see copy()
36 template<class InputIterator, class Size, class OutputIterator>
37 inline OutputIterator copy_n(InputIterator first,
38 Size count,
39 OutputIterator result,
40 command_queue &queue = system::default_queue())
41 {
42 typedef typename std::iterator_traits<InputIterator>::difference_type difference_type;
43
44 return ::boost::compute::copy(first,
45 first + static_cast<difference_type>(count),
46 result,
47 queue);
48 }
49
50 } // end compute namespace
51 } // end boost namespace
52
53 #endif // BOOST_COMPUTE_ALGORITHM_COPY_N_HPP