Output array portals are const in worklets, yet `Set` can be called on them.
Going through the user guide, example 21.2:
struct ReverseArrayCopyWorklet : vtkm::worklet::WorkletMapField
{
using ControlSignature = void(FieldIn inputArray, WholeArrayOut outputArray);
using ExecutionSignature = void(_1, _2, WorkIndex);
using InputDomain = _1;
template<typename InputType, typename OutputArrayPortalType>
VTKM_EXEC void operator()(const InputType& inputValue,
const OutputArrayPortalType& outputArrayPortal,
vtkm::Id workIndex) const
{
vtkm::Id outIndex = outputArrayPortal.GetNumberOfValues() - workIndex - 1;
if (outIndex >= 0) {
outputArrayPortal.Set(outIndex, inputValue);
}
else {
this->RaiseError("Output array not sized correctly");
}
}
};
We see that the outputArrayPortal
is marked const &
, yet we can still call the .Set
method on it.
Is this desired behavior?
Note: I have verified that this example compiles and runs correctly, but it feels like it could lead to subtle issues.