Skip to content

Allow Variant to be trivial

Kenneth Moreland requested to merge kmorel/vtk-m:variant-is-trivial into master

Although vtkm::internal::Variant respected the trivially copyable attribute of the types it contains, it was never totally trivial (i.e. std::is_trivial<Variant<...>> was never true). The reason was that Variant was initializing its Index parameter to signify that it was not initialized. However, the fact that Index was initialized meant that it was not trivially constructed.

Now, Variant type checks its types to see if they are all trivially constructible. If so, it makes itself trivially constructible.

This means that Index may or may not be valid if Variant is constructed without an argument. This in turn means that the result of Variant::IsValid becomes undefined. That should be OK in practice. Index will "point" to an uninitialized object, but that object is trivially constructed anyway. However, that could cause problems if developers used IsValid to determine if something is selected.

Merge request reports

Loading