thrust::copy#
Overloads#
copy(exec, first, last, result)#
-
template<typename DerivedPolicy, typename InputIterator, typename OutputIterator>
OutputIterator thrust::copy( - const thrust::detail::execution_policy_base<DerivedPolicy> &exec,
- InputIterator first,
- InputIterator last,
- OutputIterator result,
copycopies elements from the range [first,last) to the range [result,result+ (last-first)). That is, it performs the assignments *result= *first, *(result+1) = *(first+1), and so on. Generally, for every integernfrom0tolast-first,copyperforms the assignment *(result+n) = *(first+n). Unlikestd::copy,copyoffers no guarantee on order of operation. As a result, callingcopywith overlapping source and destination ranges has undefined behavior.The return value is
result+ (last-first).The algorithm’s execution is parallelized as determined by
exec.The following code snippet demonstrates how to use
copyto copy from one range to another using thethrust::deviceparallelization policy:#include <thrust/copy.h> #include <thrust/device_vector.h> #include <thrust/execution_policy.h> ... thrust::device_vector<int> vec0(100); thrust::device_vector<int> vec1(100); ... thrust::copy(thrust::device, vec0.begin(), vec0.end(), vec1.begin()); // vec1 is now a copy of vec0
- Parameters:
exec – The execution policy to use for parallelization.
first – The beginning of the sequence to copy.
last – The end of the sequence to copy.
result – The destination sequence.
- Template Parameters:
DerivedPolicy – The name of the derived execution policy.
InputIterator – must be a model of Input Iterator and
InputIterator'svalue_typemust be convertible toOutputIterator'svalue_type.OutputIterator – must be a model of Output Iterator.
- Returns:
The end of the destination sequence.
- Pre:
resultmay be equal tofirst, butresultshall not be in the range[first, last)otherwise.
copy(first, last, result)#
-
template<typename InputIterator, typename OutputIterator>
OutputIterator thrust::copy( - InputIterator first,
- InputIterator last,
- OutputIterator result,
copycopies elements from the range [first,last) to the range [result,result+ (last-first)). That is, it performs the assignments *result= *first, *(result+1) = *(first+1), and so on. Generally, for every integernfrom0tolast-first,copyperforms the assignment *(result+n) = *(first+n). Unlikestd::copy,copyoffers no guarantee on order of operation. As a result, callingcopywith overlapping source and destination ranges has undefined behavior.The return value is
result+ (last-first).The following code snippet demonstrates how to use
copyto copy from one range to another.#include <thrust/copy.h> #include <thrust/device_vector.h> ... thrust::device_vector<int> vec0(100); thrust::device_vector<int> vec1(100); ... thrust::copy(vec0.begin(), vec0.end(), vec1.begin()); // vec1 is now a copy of vec0
- Parameters:
first – The beginning of the sequence to copy.
last – The end of the sequence to copy.
result – The destination sequence.
- Template Parameters:
InputIterator – must be a model of Input Iterator and
InputIterator'svalue_typemust be convertible toOutputIterator'svalue_type.OutputIterator – must be a model of Output Iterator.
- Returns:
The end of the destination sequence.
- Pre:
resultmay be equal tofirst, butresultshall not be in the range[first, last)otherwise.