mirror of
https://gitlab.kitware.com/vtk/vtk-m
synced 2024-10-08 03:18:58 +00:00
Expose the Variant helper class
For several versions, VTK-m has had a `Variant` templated class. This acts like a templated union where the object will store one of a list of types specified as the template arguments. (There are actually 2 versions for the control and execution environments, respectively.) Because this is a complex class that required several iterations to work through performance and compiler issues, `Variant` was placed in the `internal` namespace to avoid complications with backward compatibility. However, the class has been stable for a while, so let us expose this helpful tool for wider use.
This commit is contained in:
parent
ef3c4c65c9
commit
c029ac113d
12
docs/changelog/expose-variant.md
Normal file
12
docs/changelog/expose-variant.md
Normal file
@ -0,0 +1,12 @@
|
||||
# Expose the Variant helper class
|
||||
|
||||
For several versions, VTK-m has had a `Variant` templated class. This acts
|
||||
like a templated union where the object will store one of a list of types
|
||||
specified as the template arguments. (There are actually 2 versions for the
|
||||
control and execution environments, respectively.)
|
||||
|
||||
Because this is a complex class that required several iterations to work
|
||||
through performance and compiler issues, `Variant` was placed in the
|
||||
`internal` namespace to avoid complications with backward compatibility.
|
||||
However, the class has been stable for a while, so let us expose this
|
||||
helpful tool for wider use.
|
@ -15,7 +15,7 @@
|
||||
#include <vtkm/Math.h>
|
||||
#include <vtkm/VectorAnalysis.h>
|
||||
|
||||
#include <vtkm/exec/internal/Variant.h>
|
||||
#include <vtkm/exec/Variant.h>
|
||||
|
||||
// For interface class only.
|
||||
#include <vtkm/cont/ExecutionAndControlObjectBase.h>
|
||||
@ -729,7 +729,7 @@ class ImplicitFunctionMultiplexer
|
||||
: public vtkm::internal::ImplicitFunctionBase<
|
||||
ImplicitFunctionMultiplexer<ImplicitFunctionTypes...>>
|
||||
{
|
||||
vtkm::exec::internal::Variant<ImplicitFunctionTypes...> Variant;
|
||||
vtkm::exec::Variant<ImplicitFunctionTypes...> Variant;
|
||||
|
||||
using Superclass =
|
||||
vtkm::internal::ImplicitFunctionBase<ImplicitFunctionMultiplexer<ImplicitFunctionTypes...>>;
|
||||
|
@ -19,8 +19,8 @@
|
||||
#include <vtkm/cont/ArrayHandleCast.h>
|
||||
#include <vtkm/cont/ArrayHandleUniformPointCoordinates.h>
|
||||
|
||||
#include <vtkm/cont/internal/Variant.h>
|
||||
#include <vtkm/exec/internal/Variant.h>
|
||||
#include <vtkm/cont/Variant.h>
|
||||
#include <vtkm/exec/Variant.h>
|
||||
|
||||
namespace vtkm
|
||||
{
|
||||
@ -90,7 +90,7 @@ private:
|
||||
template <typename... PortalTypes>
|
||||
struct ArrayPortalMultiplexer
|
||||
{
|
||||
using PortalVariantType = vtkm::exec::internal::Variant<PortalTypes...>;
|
||||
using PortalVariantType = vtkm::exec::Variant<PortalTypes...>;
|
||||
PortalVariantType PortalVariant;
|
||||
|
||||
using ValueType = typename PortalVariantType::template TypeAt<0>::ValueType;
|
||||
@ -214,7 +214,7 @@ struct MultiplexerCreateWritePortalFunctor
|
||||
template <typename T, typename... Ss>
|
||||
struct MultiplexerArrayHandleVariantFunctor
|
||||
{
|
||||
using VariantType = vtkm::cont::internal::Variant<vtkm::cont::ArrayHandle<T, Ss>...>;
|
||||
using VariantType = vtkm::cont::Variant<vtkm::cont::ArrayHandle<T, Ss>...>;
|
||||
|
||||
template <typename StorageTag>
|
||||
VTKM_CONT VariantType operator()(vtkm::cont::internal::Storage<T, StorageTag>,
|
||||
@ -232,7 +232,7 @@ class Storage<ValueType, StorageTagMultiplexer<StorageTags...>>
|
||||
template <typename S>
|
||||
using StorageFor = vtkm::cont::internal::Storage<ValueType, S>;
|
||||
|
||||
using StorageVariant = vtkm::cont::internal::Variant<StorageFor<StorageTags>...>;
|
||||
using StorageVariant = vtkm::cont::Variant<StorageFor<StorageTags>...>;
|
||||
|
||||
VTKM_CONT static StorageVariant Variant(const std::vector<vtkm::cont::internal::Buffer>& buffers)
|
||||
{
|
||||
|
@ -125,6 +125,7 @@ set(headers
|
||||
UncertainCellSet.h
|
||||
UnknownArrayHandle.h
|
||||
UnknownCellSet.h
|
||||
Variant.h
|
||||
VariantArrayHandle.h # Deprecated, replaces with Unknown/UncertainArrayHandle.h
|
||||
)
|
||||
|
||||
|
@ -16,7 +16,7 @@
|
||||
|
||||
#include <vtkm/exec/CellLocatorMultiplexer.h>
|
||||
|
||||
#include <vtkm/cont/internal/Variant.h>
|
||||
#include <vtkm/cont/Variant.h>
|
||||
|
||||
#include <functional>
|
||||
#include <memory>
|
||||
@ -60,7 +60,7 @@ public:
|
||||
vtkm::cont::Token& token) const;
|
||||
|
||||
private:
|
||||
vtkm::cont::internal::ListAsVariant<ContLocatorList> LocatorImpl;
|
||||
vtkm::cont::ListAsVariant<ContLocatorList> LocatorImpl;
|
||||
|
||||
friend Superclass;
|
||||
VTKM_CONT void Build();
|
||||
|
@ -41,7 +41,6 @@ set(headers
|
||||
RuntimeDeviceOption.h
|
||||
StorageDeprecated.h
|
||||
StorageError.h
|
||||
Variant.h
|
||||
)
|
||||
|
||||
vtkm_declare_headers(${headers})
|
||||
|
@ -32,6 +32,7 @@ set(headers
|
||||
ParametricCoordinates.h
|
||||
PointLocatorSparseGrid.h
|
||||
TaskBase.h
|
||||
Variant.h
|
||||
)
|
||||
|
||||
set(header_impls
|
||||
|
@ -13,7 +13,7 @@
|
||||
#include <vtkm/ErrorCode.h>
|
||||
#include <vtkm/TypeList.h>
|
||||
|
||||
#include <vtkm/exec/internal/Variant.h>
|
||||
#include <vtkm/exec/Variant.h>
|
||||
|
||||
namespace vtkm
|
||||
{
|
||||
@ -55,12 +55,12 @@ struct FindCellFunctor
|
||||
template <typename... LocatorTypes>
|
||||
class VTKM_ALWAYS_EXPORT CellLocatorMultiplexer
|
||||
{
|
||||
vtkm::exec::internal::Variant<LocatorTypes...> Locators;
|
||||
vtkm::exec::Variant<LocatorTypes...> Locators;
|
||||
|
||||
public:
|
||||
CellLocatorMultiplexer() = default;
|
||||
|
||||
using LastCell = vtkm::exec::internal::Variant<typename LocatorTypes::LastCell...>;
|
||||
using LastCell = vtkm::exec::Variant<typename LocatorTypes::LastCell...>;
|
||||
|
||||
template <typename Locator>
|
||||
VTKM_CONT CellLocatorMultiplexer(const Locator& locator)
|
||||
|
@ -14,7 +14,6 @@ set(headers
|
||||
ReduceByKeyLookup.h
|
||||
TaskSingular.h
|
||||
TwoLevelUniformGridExecutionObject.h
|
||||
Variant.h
|
||||
WorkletInvokeFunctorDetail.h
|
||||
)
|
||||
|
||||
|
@ -8,7 +8,7 @@
|
||||
// PURPOSE. See the above copyright notice for more information.
|
||||
//============================================================================
|
||||
|
||||
#include <vtkm/exec/internal/Variant.h>
|
||||
#include <vtkm/exec/Variant.h>
|
||||
|
||||
#include <vtkm/testing/Testing.h>
|
||||
|
||||
@ -93,7 +93,7 @@ void TestSize()
|
||||
{
|
||||
std::cout << "Test size" << std::endl;
|
||||
|
||||
using VariantType = vtkm::exec::internal::Variant<float, double, char, short, int, long>;
|
||||
using VariantType = vtkm::exec::Variant<float, double, char, short, int, long>;
|
||||
|
||||
constexpr size_t variantSize = sizeof(VariantType);
|
||||
|
||||
@ -106,36 +106,36 @@ void TestIndexing()
|
||||
{
|
||||
std::cout << "Test indexing" << std::endl;
|
||||
|
||||
using VariantType = vtkm::exec::internal::Variant<TypePlaceholder<0>,
|
||||
TypePlaceholder<1>,
|
||||
TypePlaceholder<2>,
|
||||
TypePlaceholder<3>,
|
||||
TypePlaceholder<4>,
|
||||
TypePlaceholder<5>,
|
||||
TypePlaceholder<6>,
|
||||
TypePlaceholder<7>,
|
||||
TypePlaceholder<8>,
|
||||
TypePlaceholder<9>,
|
||||
TypePlaceholder<10>,
|
||||
TypePlaceholder<11>,
|
||||
TypePlaceholder<12>,
|
||||
TypePlaceholder<13>,
|
||||
TypePlaceholder<14>,
|
||||
TypePlaceholder<15>,
|
||||
TypePlaceholder<16>,
|
||||
TypePlaceholder<17>,
|
||||
TypePlaceholder<18>,
|
||||
TypePlaceholder<19>,
|
||||
TypePlaceholder<20>,
|
||||
TypePlaceholder<21>,
|
||||
TypePlaceholder<22>,
|
||||
TypePlaceholder<23>,
|
||||
TypePlaceholder<24>,
|
||||
TypePlaceholder<25>,
|
||||
TypePlaceholder<26>,
|
||||
TypePlaceholder<27>,
|
||||
TypePlaceholder<28>,
|
||||
TypePlaceholder<29>>;
|
||||
using VariantType = vtkm::exec::Variant<TypePlaceholder<0>,
|
||||
TypePlaceholder<1>,
|
||||
TypePlaceholder<2>,
|
||||
TypePlaceholder<3>,
|
||||
TypePlaceholder<4>,
|
||||
TypePlaceholder<5>,
|
||||
TypePlaceholder<6>,
|
||||
TypePlaceholder<7>,
|
||||
TypePlaceholder<8>,
|
||||
TypePlaceholder<9>,
|
||||
TypePlaceholder<10>,
|
||||
TypePlaceholder<11>,
|
||||
TypePlaceholder<12>,
|
||||
TypePlaceholder<13>,
|
||||
TypePlaceholder<14>,
|
||||
TypePlaceholder<15>,
|
||||
TypePlaceholder<16>,
|
||||
TypePlaceholder<17>,
|
||||
TypePlaceholder<18>,
|
||||
TypePlaceholder<19>,
|
||||
TypePlaceholder<20>,
|
||||
TypePlaceholder<21>,
|
||||
TypePlaceholder<22>,
|
||||
TypePlaceholder<23>,
|
||||
TypePlaceholder<24>,
|
||||
TypePlaceholder<25>,
|
||||
TypePlaceholder<26>,
|
||||
TypePlaceholder<27>,
|
||||
TypePlaceholder<28>,
|
||||
TypePlaceholder<29>>;
|
||||
|
||||
VariantType variant;
|
||||
|
||||
@ -256,51 +256,48 @@ void TestTriviallyCopyable()
|
||||
VTKM_STATIC_ASSERT(!vtkmstd::is_trivial<TrivialCopy>::value);
|
||||
|
||||
// A variant of trivially constructable things should be trivially constructable
|
||||
VTKM_STATIC_ASSERT((vtkmstd::is_trivially_constructible<
|
||||
vtkm::exec::internal::detail::VariantUnion<float, int>>::value));
|
||||
VTKM_STATIC_ASSERT(
|
||||
(vtkmstd::is_trivially_constructible<vtkm::exec::internal::Variant<float, int>>::value));
|
||||
(vtkmstd::is_trivially_constructible<vtkm::exec::detail::VariantUnion<float, int>>::value));
|
||||
VTKM_STATIC_ASSERT((vtkmstd::is_trivially_constructible<vtkm::exec::Variant<float, int>>::value));
|
||||
|
||||
// A variant of trivially copyable things should be trivially copyable
|
||||
VTKM_STATIC_ASSERT((vtkmstd::is_trivially_copyable<
|
||||
vtkm::exec::internal::detail::VariantUnion<float, int, TrivialCopy>>::value));
|
||||
VTKM_STATIC_ASSERT((
|
||||
vtkmstd::is_trivially_copyable<vtkm::exec::internal::Variant<float, int, TrivialCopy>>::value));
|
||||
vtkm::exec::detail::VariantUnion<float, int, TrivialCopy>>::value));
|
||||
VTKM_STATIC_ASSERT(
|
||||
(vtkmstd::is_trivially_copyable<vtkm::exec::Variant<float, int, TrivialCopy>>::value));
|
||||
|
||||
// A variant of any non-trivially constructable things is not trivially copyable
|
||||
VTKM_STATIC_ASSERT((!vtkmstd::is_trivially_constructible<
|
||||
vtkm::exec::internal::detail::VariantUnion<NonTrivial, float, int>>::value));
|
||||
vtkm::exec::detail::VariantUnion<NonTrivial, float, int>>::value));
|
||||
VTKM_STATIC_ASSERT((!vtkmstd::is_trivially_constructible<
|
||||
vtkm::exec::internal::detail::VariantUnion<float, NonTrivial, int>>::value));
|
||||
vtkm::exec::detail::VariantUnion<float, NonTrivial, int>>::value));
|
||||
VTKM_STATIC_ASSERT((!vtkmstd::is_trivially_constructible<
|
||||
vtkm::exec::internal::detail::VariantUnion<float, int, NonTrivial>>::value));
|
||||
VTKM_STATIC_ASSERT((!vtkmstd::is_trivially_constructible<
|
||||
vtkm::exec::internal::Variant<NonTrivial, float, int>>::value));
|
||||
VTKM_STATIC_ASSERT((!vtkmstd::is_trivially_constructible<
|
||||
vtkm::exec::internal::Variant<float, NonTrivial, int>>::value));
|
||||
VTKM_STATIC_ASSERT((!vtkmstd::is_trivially_constructible<
|
||||
vtkm::exec::internal::Variant<float, int, NonTrivial>>::value));
|
||||
vtkm::exec::detail::VariantUnion<float, int, NonTrivial>>::value));
|
||||
VTKM_STATIC_ASSERT(
|
||||
(!vtkmstd::is_trivially_constructible<vtkm::exec::Variant<NonTrivial, float, int>>::value));
|
||||
VTKM_STATIC_ASSERT(
|
||||
(!vtkmstd::is_trivially_constructible<vtkm::exec::Variant<float, NonTrivial, int>>::value));
|
||||
VTKM_STATIC_ASSERT(
|
||||
(!vtkmstd::is_trivially_constructible<vtkm::exec::Variant<float, int, NonTrivial>>::value));
|
||||
|
||||
// A variant of any non-trivially copyable things is not trivially copyable
|
||||
VTKM_STATIC_ASSERT((!vtkmstd::is_trivially_copyable<
|
||||
vtkm::exec::internal::detail::VariantUnion<NonTrivial, float, int>>::value));
|
||||
vtkm::exec::detail::VariantUnion<NonTrivial, float, int>>::value));
|
||||
VTKM_STATIC_ASSERT((!vtkmstd::is_trivially_copyable<
|
||||
vtkm::exec::internal::detail::VariantUnion<float, NonTrivial, int>>::value));
|
||||
vtkm::exec::detail::VariantUnion<float, NonTrivial, int>>::value));
|
||||
VTKM_STATIC_ASSERT((!vtkmstd::is_trivially_copyable<
|
||||
vtkm::exec::internal::detail::VariantUnion<float, int, NonTrivial>>::value));
|
||||
VTKM_STATIC_ASSERT((
|
||||
!vtkmstd::is_trivially_copyable<vtkm::exec::internal::Variant<NonTrivial, float, int>>::value));
|
||||
VTKM_STATIC_ASSERT((
|
||||
!vtkmstd::is_trivially_copyable<vtkm::exec::internal::Variant<float, NonTrivial, int>>::value));
|
||||
VTKM_STATIC_ASSERT((
|
||||
!vtkmstd::is_trivially_copyable<vtkm::exec::internal::Variant<float, int, NonTrivial>>::value));
|
||||
vtkm::exec::detail::VariantUnion<float, int, NonTrivial>>::value));
|
||||
VTKM_STATIC_ASSERT(
|
||||
(!vtkmstd::is_trivially_copyable<vtkm::exec::Variant<NonTrivial, float, int>>::value));
|
||||
VTKM_STATIC_ASSERT(
|
||||
(!vtkmstd::is_trivially_copyable<vtkm::exec::Variant<float, NonTrivial, int>>::value));
|
||||
VTKM_STATIC_ASSERT(
|
||||
(!vtkmstd::is_trivially_copyable<vtkm::exec::Variant<float, int, NonTrivial>>::value));
|
||||
|
||||
// A variant of trivial things should be trivial
|
||||
VTKM_STATIC_ASSERT((vtkmstd::is_trivial<vtkm::exec::internal::Variant<float, int>>::value));
|
||||
VTKM_STATIC_ASSERT(
|
||||
(!vtkmstd::is_trivial<vtkm::exec::internal::Variant<float, int, TrivialCopy>>::value));
|
||||
VTKM_STATIC_ASSERT(
|
||||
(!vtkmstd::is_trivial<vtkm::exec::internal::Variant<float, int, NonTrivial>>::value));
|
||||
VTKM_STATIC_ASSERT((vtkmstd::is_trivial<vtkm::exec::Variant<float, int>>::value));
|
||||
VTKM_STATIC_ASSERT((!vtkmstd::is_trivial<vtkm::exec::Variant<float, int, TrivialCopy>>::value));
|
||||
VTKM_STATIC_ASSERT((!vtkmstd::is_trivial<vtkm::exec::Variant<float, int, NonTrivial>>::value));
|
||||
#endif // VTKM_USE_STD_IS_TRIVIAL
|
||||
}
|
||||
|
||||
@ -329,36 +326,36 @@ void TestGet()
|
||||
{
|
||||
std::cout << "Test Get" << std::endl;
|
||||
|
||||
using VariantType = vtkm::exec::internal::Variant<TypePlaceholder<0>,
|
||||
TypePlaceholder<1>,
|
||||
vtkm::Id,
|
||||
TypePlaceholder<3>,
|
||||
TypePlaceholder<4>,
|
||||
TypePlaceholder<5>,
|
||||
TypePlaceholder<6>,
|
||||
TypePlaceholder<7>,
|
||||
TypePlaceholder<8>,
|
||||
TypePlaceholder<9>,
|
||||
TypePlaceholder<10>,
|
||||
TypePlaceholder<11>,
|
||||
TypePlaceholder<12>,
|
||||
TypePlaceholder<13>,
|
||||
TypePlaceholder<14>,
|
||||
TypePlaceholder<15>,
|
||||
TypePlaceholder<16>,
|
||||
TypePlaceholder<17>,
|
||||
TypePlaceholder<18>,
|
||||
TypePlaceholder<19>,
|
||||
TypePlaceholder<20>,
|
||||
TypePlaceholder<21>,
|
||||
TypePlaceholder<22>,
|
||||
TypePlaceholder<23>,
|
||||
TypePlaceholder<24>,
|
||||
TypePlaceholder<25>,
|
||||
TypePlaceholder<26>,
|
||||
vtkm::Float32,
|
||||
TypePlaceholder<28>,
|
||||
TypePlaceholder<29>>;
|
||||
using VariantType = vtkm::exec::Variant<TypePlaceholder<0>,
|
||||
TypePlaceholder<1>,
|
||||
vtkm::Id,
|
||||
TypePlaceholder<3>,
|
||||
TypePlaceholder<4>,
|
||||
TypePlaceholder<5>,
|
||||
TypePlaceholder<6>,
|
||||
TypePlaceholder<7>,
|
||||
TypePlaceholder<8>,
|
||||
TypePlaceholder<9>,
|
||||
TypePlaceholder<10>,
|
||||
TypePlaceholder<11>,
|
||||
TypePlaceholder<12>,
|
||||
TypePlaceholder<13>,
|
||||
TypePlaceholder<14>,
|
||||
TypePlaceholder<15>,
|
||||
TypePlaceholder<16>,
|
||||
TypePlaceholder<17>,
|
||||
TypePlaceholder<18>,
|
||||
TypePlaceholder<19>,
|
||||
TypePlaceholder<20>,
|
||||
TypePlaceholder<21>,
|
||||
TypePlaceholder<22>,
|
||||
TypePlaceholder<23>,
|
||||
TypePlaceholder<24>,
|
||||
TypePlaceholder<25>,
|
||||
TypePlaceholder<26>,
|
||||
vtkm::Float32,
|
||||
TypePlaceholder<28>,
|
||||
TypePlaceholder<29>>;
|
||||
|
||||
{
|
||||
const vtkm::Id expectedValue = TestValue(3, vtkm::Id{});
|
||||
@ -392,36 +389,36 @@ void TestCastAndCall()
|
||||
{
|
||||
std::cout << "Test CastAndCall" << std::endl;
|
||||
|
||||
using VariantType = vtkm::exec::internal::Variant<TypePlaceholder<0>,
|
||||
TypePlaceholder<1>,
|
||||
TypePlaceholder<2>,
|
||||
TypePlaceholder<3>,
|
||||
TypePlaceholder<4>,
|
||||
TypePlaceholder<5>,
|
||||
TypePlaceholder<6>,
|
||||
TypePlaceholder<7>,
|
||||
TypePlaceholder<8>,
|
||||
TypePlaceholder<9>,
|
||||
TypePlaceholder<10>,
|
||||
TypePlaceholder<11>,
|
||||
TypePlaceholder<12>,
|
||||
TypePlaceholder<13>,
|
||||
TypePlaceholder<14>,
|
||||
TypePlaceholder<15>,
|
||||
TypePlaceholder<16>,
|
||||
TypePlaceholder<17>,
|
||||
TypePlaceholder<18>,
|
||||
TypePlaceholder<19>,
|
||||
TypePlaceholder<20>,
|
||||
TypePlaceholder<21>,
|
||||
TypePlaceholder<22>,
|
||||
TypePlaceholder<23>,
|
||||
TypePlaceholder<24>,
|
||||
TypePlaceholder<25>,
|
||||
TypePlaceholder<26>,
|
||||
TypePlaceholder<27>,
|
||||
TypePlaceholder<28>,
|
||||
TypePlaceholder<29>>;
|
||||
using VariantType = vtkm::exec::Variant<TypePlaceholder<0>,
|
||||
TypePlaceholder<1>,
|
||||
TypePlaceholder<2>,
|
||||
TypePlaceholder<3>,
|
||||
TypePlaceholder<4>,
|
||||
TypePlaceholder<5>,
|
||||
TypePlaceholder<6>,
|
||||
TypePlaceholder<7>,
|
||||
TypePlaceholder<8>,
|
||||
TypePlaceholder<9>,
|
||||
TypePlaceholder<10>,
|
||||
TypePlaceholder<11>,
|
||||
TypePlaceholder<12>,
|
||||
TypePlaceholder<13>,
|
||||
TypePlaceholder<14>,
|
||||
TypePlaceholder<15>,
|
||||
TypePlaceholder<16>,
|
||||
TypePlaceholder<17>,
|
||||
TypePlaceholder<18>,
|
||||
TypePlaceholder<19>,
|
||||
TypePlaceholder<20>,
|
||||
TypePlaceholder<21>,
|
||||
TypePlaceholder<22>,
|
||||
TypePlaceholder<23>,
|
||||
TypePlaceholder<24>,
|
||||
TypePlaceholder<25>,
|
||||
TypePlaceholder<26>,
|
||||
TypePlaceholder<27>,
|
||||
TypePlaceholder<28>,
|
||||
TypePlaceholder<29>>;
|
||||
vtkm::FloatDefault result;
|
||||
|
||||
VariantType variant0{ TypePlaceholder<0>{} };
|
||||
@ -454,7 +451,7 @@ void TestCopyInvalid()
|
||||
{
|
||||
std::cout << "Test copy invalid variant" << std::endl;
|
||||
|
||||
using VariantType = vtkm::exec::internal::Variant<TypePlaceholder<0>, NonTrivial>;
|
||||
using VariantType = vtkm::exec::Variant<TypePlaceholder<0>, NonTrivial>;
|
||||
|
||||
VariantType source;
|
||||
source.Reset();
|
||||
@ -488,11 +485,11 @@ void TestCopyDestroy()
|
||||
{
|
||||
std::cout << "Test copy destroy" << std::endl;
|
||||
|
||||
using VariantType = vtkm::exec::internal::Variant<TypePlaceholder<0>,
|
||||
TypePlaceholder<1>,
|
||||
CountConstructDestruct,
|
||||
TypePlaceholder<3>,
|
||||
TypePlaceholder<4>>;
|
||||
using VariantType = vtkm::exec::Variant<TypePlaceholder<0>,
|
||||
TypePlaceholder<1>,
|
||||
CountConstructDestruct,
|
||||
TypePlaceholder<3>,
|
||||
TypePlaceholder<4>>;
|
||||
#ifdef VTKM_USE_STD_IS_TRIVIAL
|
||||
VTKM_STATIC_ASSERT(!vtkmstd::is_trivially_copyable<VariantType>::value);
|
||||
#endif // VTKM_USE_STD_IS_TRIVIAL
|
||||
@ -545,7 +542,7 @@ void TestEmplace()
|
||||
{
|
||||
std::cout << "Test Emplace" << std::endl;
|
||||
|
||||
using VariantType = vtkm::exec::internal::Variant<vtkm::Id, vtkm::Id3, std::vector<vtkm::Id>>;
|
||||
using VariantType = vtkm::exec::Variant<vtkm::Id, vtkm::Id3, std::vector<vtkm::Id>>;
|
||||
|
||||
VariantType variant;
|
||||
variant.Emplace<vtkm::Id>(TestValue(0, vtkm::Id{}));
|
||||
@ -577,7 +574,7 @@ void TestConstructDestruct()
|
||||
|
||||
g_NonTrivialCount = 0;
|
||||
|
||||
using VariantType = vtkm::exec::internal::Variant<NonTrivial, TrivialCopy>;
|
||||
using VariantType = vtkm::exec::Variant<NonTrivial, TrivialCopy>;
|
||||
|
||||
{
|
||||
VariantType variant1 = NonTrivial{};
|
||||
@ -597,8 +594,7 @@ void TestCopySelf()
|
||||
{
|
||||
std::cout << "Make sure copying a Variant to itself works" << std::endl;
|
||||
|
||||
using VariantType =
|
||||
vtkm::exec::internal::Variant<TypePlaceholder<0>, NonTrivial, TypePlaceholder<2>>;
|
||||
using VariantType = vtkm::exec::Variant<TypePlaceholder<0>, NonTrivial, TypePlaceholder<2>>;
|
||||
|
||||
VariantType variant{ NonTrivial{} };
|
||||
VariantType& variantRef = variant;
|
||||
|
@ -26,8 +26,7 @@ namespace
|
||||
VTKM_CONT std::vector<vtkm::filter::flow::internal::DataSetIntegratorSteadyState>
|
||||
CreateDataSetIntegrators(
|
||||
const vtkm::cont::PartitionedDataSet& input,
|
||||
const vtkm::cont::internal::Variant<std::string, std::pair<std::string, std::string>>&
|
||||
activeField,
|
||||
const vtkm::cont::Variant<std::string, std::pair<std::string, std::string>>& activeField,
|
||||
const vtkm::filter::flow::internal::BoundsMap& boundsMap,
|
||||
const vtkm::filter::flow::IntegrationSolverType solverType,
|
||||
const vtkm::filter::flow::VectorFieldType vecFieldType,
|
||||
@ -69,8 +68,7 @@ VTKM_CONT vtkm::cont::PartitionedDataSet NewFilterParticleAdvectionSteadyState::
|
||||
using DSIType = vtkm::filter::flow::internal::DataSetIntegratorSteadyState;
|
||||
this->ValidateOptions();
|
||||
|
||||
using VariantType =
|
||||
vtkm::cont::internal::Variant<std::string, std::pair<std::string, std::string>>;
|
||||
using VariantType = vtkm::cont::Variant<std::string, std::pair<std::string, std::string>>;
|
||||
VariantType variant;
|
||||
|
||||
if (this->VecFieldType == vtkm::filter::flow::VectorFieldType::VELOCITY_FIELD_TYPE)
|
||||
|
@ -22,7 +22,7 @@
|
||||
#include <vtkm/filter/flow/worklet/RK4Integrator.h>
|
||||
#include <vtkm/filter/flow/worklet/Stepper.h>
|
||||
|
||||
#include <vtkm/cont/internal/Variant.h>
|
||||
#include <vtkm/cont/Variant.h>
|
||||
|
||||
namespace vtkm
|
||||
{
|
||||
@ -54,8 +54,8 @@ public:
|
||||
std::vector<vtkm::Id> TermIdx, TermID;
|
||||
};
|
||||
|
||||
using DSIHelperInfoType = vtkm::cont::internal::Variant<DSIHelperInfo<vtkm::Particle>,
|
||||
DSIHelperInfo<vtkm::ChargedParticle>>;
|
||||
using DSIHelperInfoType =
|
||||
vtkm::cont::Variant<DSIHelperInfo<vtkm::Particle>, DSIHelperInfo<vtkm::ChargedParticle>>;
|
||||
|
||||
template <typename Derived>
|
||||
class DataSetIntegrator
|
||||
@ -65,14 +65,13 @@ public:
|
||||
using ElectroMagneticFieldNameType = std::pair<std::string, std::string>;
|
||||
|
||||
protected:
|
||||
using FieldNameType =
|
||||
vtkm::cont::internal::Variant<VelocityFieldNameType, ElectroMagneticFieldNameType>;
|
||||
using FieldNameType = vtkm::cont::Variant<VelocityFieldNameType, ElectroMagneticFieldNameType>;
|
||||
|
||||
using RType = vtkm::cont::internal::Variant<
|
||||
vtkm::worklet::flow::ParticleAdvectionResult<vtkm::Particle>,
|
||||
vtkm::worklet::flow::ParticleAdvectionResult<vtkm::ChargedParticle>,
|
||||
vtkm::worklet::flow::StreamlineResult<vtkm::Particle>,
|
||||
vtkm::worklet::flow::StreamlineResult<vtkm::ChargedParticle>>;
|
||||
using RType =
|
||||
vtkm::cont::Variant<vtkm::worklet::flow::ParticleAdvectionResult<vtkm::Particle>,
|
||||
vtkm::worklet::flow::ParticleAdvectionResult<vtkm::ChargedParticle>,
|
||||
vtkm::worklet::flow::StreamlineResult<vtkm::Particle>,
|
||||
vtkm::worklet::flow::StreamlineResult<vtkm::ChargedParticle>>;
|
||||
|
||||
public:
|
||||
DataSetIntegrator(vtkm::Id id,
|
||||
@ -128,7 +127,7 @@ protected:
|
||||
DSIHelperInfo<ParticleType>& dsiInfo) const;
|
||||
|
||||
//Data members.
|
||||
vtkm::cont::internal::Variant<VelocityFieldNameType, ElectroMagneticFieldNameType> FieldName;
|
||||
vtkm::cont::Variant<VelocityFieldNameType, ElectroMagneticFieldNameType> FieldName;
|
||||
|
||||
vtkm::Id Id;
|
||||
vtkm::filter::flow::IntegrationSolverType SolverType;
|
||||
|
@ -26,8 +26,6 @@ namespace vtkm
|
||||
{
|
||||
namespace VTK_M_NAMESPACE
|
||||
{
|
||||
namespace internal
|
||||
{
|
||||
|
||||
// Forward declaration
|
||||
template <typename... Ts>
|
||||
@ -126,8 +124,7 @@ template <typename VariantType>
|
||||
struct VariantTriviallyCopyable;
|
||||
|
||||
template <typename... Ts>
|
||||
struct VariantTriviallyCopyable<vtkm::VTK_M_NAMESPACE::internal::Variant<Ts...>>
|
||||
: AllTriviallyCopyable<Ts...>
|
||||
struct VariantTriviallyCopyable<vtkm::VTK_M_NAMESPACE::Variant<Ts...>> : AllTriviallyCopyable<Ts...>
|
||||
{
|
||||
};
|
||||
|
||||
@ -135,7 +132,7 @@ template <typename VariantType>
|
||||
struct VariantTriviallyConstructible;
|
||||
|
||||
template <typename... Ts>
|
||||
struct VariantTriviallyConstructible<vtkm::VTK_M_NAMESPACE::internal::Variant<Ts...>>
|
||||
struct VariantTriviallyConstructible<vtkm::VTK_M_NAMESPACE::Variant<Ts...>>
|
||||
: AllTriviallyConstructible<Ts...>
|
||||
{
|
||||
};
|
||||
@ -205,9 +202,8 @@ struct VariantConstructorImpl;
|
||||
|
||||
// Can trivially construct, deconstruct, and copy all data. (Probably all trivial classes.)
|
||||
template <typename... Ts>
|
||||
struct VariantConstructorImpl<vtkm::VTK_M_NAMESPACE::internal::Variant<Ts...>,
|
||||
std::true_type,
|
||||
std::true_type> : VariantStorageImpl<Ts...>
|
||||
struct VariantConstructorImpl<vtkm::VTK_M_NAMESPACE::Variant<Ts...>, std::true_type, std::true_type>
|
||||
: VariantStorageImpl<Ts...>
|
||||
{
|
||||
VariantConstructorImpl() = default;
|
||||
~VariantConstructorImpl() = default;
|
||||
@ -221,7 +217,7 @@ struct VariantConstructorImpl<vtkm::VTK_M_NAMESPACE::internal::Variant<Ts...>,
|
||||
// Can trivially copy, but cannot trivially construct. Common if a class is simple but
|
||||
// initializes itself.
|
||||
template <typename... Ts>
|
||||
struct VariantConstructorImpl<vtkm::VTK_M_NAMESPACE::internal::Variant<Ts...>,
|
||||
struct VariantConstructorImpl<vtkm::VTK_M_NAMESPACE::Variant<Ts...>,
|
||||
std::false_type,
|
||||
std::true_type> : VariantStorageImpl<Ts...>
|
||||
{
|
||||
@ -242,7 +238,7 @@ struct VariantConstructorImpl<vtkm::VTK_M_NAMESPACE::internal::Variant<Ts...>,
|
||||
|
||||
// Cannot trivially copy. We assume we cannot trivially construct/destruct.
|
||||
template <typename construct_type, typename... Ts>
|
||||
struct VariantConstructorImpl<vtkm::VTK_M_NAMESPACE::internal::Variant<Ts...>,
|
||||
struct VariantConstructorImpl<vtkm::VTK_M_NAMESPACE::Variant<Ts...>,
|
||||
construct_type,
|
||||
std::false_type> : VariantStorageImpl<Ts...>
|
||||
{
|
||||
@ -555,15 +551,14 @@ template <typename ListTag>
|
||||
using ListTagAsVariant VTKM_DEPRECATED(
|
||||
1.6,
|
||||
"vtkm::ListTag is no longer supported. Use vtkm::List instead.") =
|
||||
vtkm::ListApply<ListTag, vtkm::VTK_M_NAMESPACE::internal::Variant>;
|
||||
vtkm::ListApply<ListTag, vtkm::VTK_M_NAMESPACE::Variant>;
|
||||
|
||||
/// \brief Convert a `List` to a `Variant`.
|
||||
///
|
||||
template <typename List>
|
||||
using ListAsVariant = vtkm::ListApply<List, vtkm::VTK_M_NAMESPACE::internal::Variant>;
|
||||
using ListAsVariant = vtkm::ListApply<List, vtkm::VTK_M_NAMESPACE::Variant>;
|
||||
}
|
||||
}
|
||||
} // namespace vtkm::VTK_M_NAMESPACE::internal
|
||||
} // namespace vtkm::VTK_M_NAMESPACE
|
||||
|
||||
#undef VTK_M_DEVICE
|
||||
#undef VTK_M_NAMESPACE
|
||||
|
@ -32,8 +32,6 @@ namespace vtkm
|
||||
{
|
||||
namespace VTK_M_NAMESPACE
|
||||
{
|
||||
namespace internal
|
||||
{
|
||||
namespace detail
|
||||
{
|
||||
|
||||
@ -1010,5 +1008,4 @@ VTK_M_DEVICE inline auto VariantCastAndCallImpl(
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
} // vtkm::VTK_M_NAMESPACE::internal::detail
|
||||
} // vtkm::VTK_M_NAMESPACE::detail
|
||||
|
@ -65,8 +65,6 @@ namespace vtkm
|
||||
{
|
||||
namespace VTK_M_NAMESPACE
|
||||
{
|
||||
namespace internal
|
||||
{
|
||||
namespace detail
|
||||
{
|
||||
|
||||
@ -354,5 +352,4 @@ VTK_M_DEVICE inline auto VariantCastAndCallImpl(
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
} // vtkm::VTK_M_NAMESPACE::internal::detail
|
||||
} // vtkm::VTK_M_NAMESPACE::detail
|
||||
|
@ -13,7 +13,7 @@
|
||||
#include <sstream>
|
||||
#include <vtkm/CellShape.h>
|
||||
#include <vtkm/cont/ErrorBadValue.h>
|
||||
#include <vtkm/exec/internal/Variant.h>
|
||||
#include <vtkm/exec/Variant.h>
|
||||
#include <vtkm/rendering/raytracing/BoundingVolumeHierarchy.h>
|
||||
#include <vtkm/rendering/raytracing/CellTables.h>
|
||||
#include <vtkm/rendering/raytracing/Logger.h>
|
||||
@ -250,7 +250,7 @@ public:
|
||||
/// \brief General version of mesh connectivity that can be used for all supported mesh types.
|
||||
class VTKM_ALWAYS_EXPORT MeshConnectivity
|
||||
{
|
||||
using ConnectivityType = vtkm::exec::internal::
|
||||
using ConnectivityType = vtkm::exec::
|
||||
Variant<MeshConnectivityStructured, MeshConnectivityUnstructured, MeshConnectivitySingleType>;
|
||||
ConnectivityType Connectivity;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user