Convert enums to enum structs
There are multiple examples in VTK-m where a class contains an enum to select a mode. For example, the vtkm::cont::Field
class as an enum for the association of a field to points, cells, etc. The problem with using enums of this nature is that the compiler will automatically convert them to int
s, which can cause some unexpected behavior.
A better approach would be to use the newer struct-based enums. These will ensure we are using the correct type. So in the case of the associations of field, we would have an implementation that looks something like this:
namespace vtkm
{
namespace cont
{
enum struct FieldAssociation
{
ANY,
WHOLE_MESH,
POINTS,
CELLS
};
class VTKM_CONT_EXPORT Field
{
Then instead of referencing a value like vtkm::cont::Field::ASSOC_ANY
, you would use vtkm::cont::FieldAssociation::ANY
.