1 //---------------------------------------------------------------------------//
2 // Copyright (c) 2013 Kyle Lutz <kyle.r.lutz@gmail.com>
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
8 // See http://boostorg.github.com/compute for more information.
9 //---------------------------------------------------------------------------//
11 #ifndef BOOST_COMPUTE_ALGORITHM_COPY_N_HPP
12 #define BOOST_COMPUTE_ALGORITHM_COPY_N_HPP
14 #include <boost/compute/system.hpp>
15 #include <boost/compute/command_queue.hpp>
16 #include <boost/compute/algorithm/copy.hpp>
21 /// Copies \p count elements from \p first to \p result.
23 /// For example, to copy four values from the host to the device:
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);
29 /// // copy from the host to the device
30 /// boost::compute::copy_n(values, 4, vec.begin(), queue);
34 template<class InputIterator, class Size, class OutputIterator>
35 inline OutputIterator copy_n(InputIterator first,
37 OutputIterator result,
38 command_queue &queue = system::default_queue())
40 typedef typename std::iterator_traits<InputIterator>::difference_type difference_type;
42 return ::boost::compute::copy(first,
43 first + static_cast<difference_type>(count),
48 } // end compute namespace
49 } // end boost namespace
51 #endif // BOOST_COMPUTE_ALGORITHM_COPY_N_HPP