Mark ArrayHandle constructors taking buffers, as explicit
This resolves a compiler ambiguity I hit during development.
In my case, I created an ArrayHandleDecorator
with one of the arrays being
an ArrayHandleTransform
. The ambiguity occurs in function
DecoratorStorageTraits<...>::BuffersToArray
[1], here an ArrayHandleTransform
is constructed using buffers (std::vector<vtkm::cont::internal::Buffer>
)
This constructor is not defined for ArrayHandleTransform
, but it's defined for
its superclass (vtkm::cont::ArrayHandle
)[2]. ArrayHandleTransform
does have a
non-explicit constructor that takes the array to be transformed and the
transform-functor as parameters, where the later has a default value[3].
This produces the following ambiguous options for the compiler:
- Create an instance of the ArrayHandle that is to be transformed, using the buffers[2], and call
the
ArrayHandleTransform
constructor with this array with the defaulted functor parameter [3]. - Create the superclass instance using the buffer[2] and call the
ArrayHandleTransform
constructor that takes the superclass[4].
In this situation, option 2 is the correct choice.
The ambiguity is resolved by marking the constructors that take
buffers as explicit. These constructors are also added for the
derived classess via the VTK_M_ARRAY_HANDLE_SUBCLASS_IMPL
macro.
- https://gitlab.kitware.com/vtk/vtk-m/-/blob/ddada34223b81e622292edc14a6ed57b6834348c/vtkm/cont/ArrayHandleDecorator.h#L363
- https://gitlab.kitware.com/vtk/vtk-m/-/blob/ddada34223b81e622292edc14a6ed57b6834348c/vtkm/cont/ArrayHandle.h#L340
- https://gitlab.kitware.com/vtk/vtk-m/-/blob/ddada34223b81e622292edc14a6ed57b6834348c/vtkm/cont/ArrayHandleTransform.h#L456
- https://gitlab.kitware.com/vtk/vtk-m/-/blob/ddada34223b81e622292edc14a6ed57b6834348c/vtkm/cont/ArrayHandle.h#L182