Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions thrust/thrust/system/cuda/detail/uninitialized_copy.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,13 @@ OutputIt _CCCL_HOST_DEVICE
uninitialized_copy_n(execution_policy<Derived>& policy, InputIt first, Size count, OutputIt result)
{
// if the output type is trivially constructible from the input, it has no side effect, and we can skip placement new
// and calling a constructor. So we can delegate to copy_n.
using ctor_arg_t = thrust::detail::raw_reference_t<::cuda::std::iter_reference_t<InputIt>>;
using output_t = thrust::detail::it_value_t<OutputIt>;
if constexpr (::cuda::std::is_trivially_constructible_v<output_t, ctor_arg_t>)
// and calling a constructor. Furthermore, if assigning an input to an output element is also trivial, there is no
// copy constructor which could have a side effect and we can delegate to copy_n.
using input_ref_t = thrust::detail::raw_reference_t<::cuda::std::iter_reference_t<InputIt>>;
using output_ref_t = thrust::detail::raw_reference_t<::cuda::std::iter_reference_t<OutputIt>>;
using output_t = thrust::detail::it_value_t<OutputIt>;
if constexpr (::cuda::std::is_trivially_constructible_v<output_t, input_ref_t>
&& ::cuda::std::is_trivially_assignable_v<output_ref_t, input_ref_t>)
{
cuda_cub::copy_n(policy, first, count, result);
}
Expand Down