Skip to content

Allow ArrayCopy into const ref of UnknownArrayHandle

Kenneth Moreland requested to merge kmorel/vtk-m:array-copy-const-ref into master

Added the following form of ArrayCopy:

VTKM_CONT_EXPORT void ArrayCopy(
  const vtkm::cont::UnknownArrayHandle& source,
  const vtkm::cont::UnknownArrayHandle& destination);

Note that the destination array is a constant reference. This is actually OK because you can change the contents of an UnknownArrayHandle (as long as you don't change the array being referenced). The main motivation for this change is to allow you to call this form of ArrayCopy while passing in a ArrayHandle as the second argument. C++ will automatically make the conversion, but the function has to accept a const reference for it to be passed correctly.

Note that there is still a form of ArrayCopy that accepts a non-const reference to the destination array. The two arrays behave the same except for one difference. For the non-const version, if the UnknownArrayHandle does not already point to an array (i.e. is not valid), a new array will be created and placed in the destination object. However, because this cannot be done for a const reference, an exception is thrown instead.

Merge request reports

Loading