]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/boost/compute/algorithm/copy_n.hpp
import new upstream nautilus stable release 14.2.8
[ceph.git] / ceph / src / boost / boost / compute / algorithm / copy_n.hpp
CommitLineData
7c673cae
FG
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
18namespace boost {
19namespace 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///
b32b8144
FG
33/// Space complexity: \Omega(1)
34///
7c673cae
FG
35/// \see copy()
36template<class InputIterator, class Size, class OutputIterator>
37inline OutputIterator copy_n(InputIterator first,
38 Size count,
39 OutputIterator result,
92f5a8d4
TL
40 command_queue &queue = system::default_queue(),
41 const wait_list &events = wait_list())
7c673cae
FG
42{
43 typedef typename std::iterator_traits<InputIterator>::difference_type difference_type;
44
45 return ::boost::compute::copy(first,
46 first + static_cast<difference_type>(count),
47 result,
92f5a8d4
TL
48 queue,
49 events);
7c673cae
FG
50}
51
52} // end compute namespace
53} // end boost namespace
54
55#endif // BOOST_COMPUTE_ALGORITHM_COPY_N_HPP