VTK-m  2.0
Public Types | Public Member Functions | Static Public Member Functions | Static Public Attributes | Private Types | Private Member Functions | List of all members
vtkm::VTK_M_NAMESPACE::Variant< Ts > Class Template Reference

#include <VariantImpl.h>

Public Types

template<typename T >
using IndexOf = vtkm::ListIndexOf< vtkm::List< Ts... >, T >
 Type that converts to a std::integral_constant containing the index of the given type (or -1 if that type is not in the list). More...
 
template<vtkm::IdComponent Index>
using TypeAt = typename vtkm::ListAt< vtkm::List< Ts... >, Index >
 Type that converts to the type at the given index. More...
 
template<typename T >
using CanStore = std::integral_constant< bool,(IndexOf< T >::value >=0)>
 Type that indicates whether another type can be stored in this Variant. More...
 

Public Member Functions

VTK_M_DEVICE vtkm::IdComponent GetIndex () const noexcept
 Returns the index of the type of object this variant is storing. More...
 
VTK_M_DEVICE bool IsValid () const noexcept
 Returns true if this Variant is storing an object from one of the types in the template list, false otherwise. More...
 
template<typename T >
VTK_M_DEVICE bool IsType () const
 Returns true if this Variant stores the given type. More...
 
 Variant ()=default
 
 ~Variant ()=default
 
 Variant (const Variant &)=default
 
 Variant (Variant &&)=default
 
Variantoperator= (const Variant &)=default
 
Variantoperator= (Variant &&)=default
 
template<typename T >
VTK_M_DEVICE Variant (const T &src) noexcept
 
template<typename T >
VTK_M_DEVICE Variantoperator= (const T &src)
 
template<typename T , typename... Args>
VTK_M_DEVICE T & Emplace (Args &&... args)
 
template<typename T , typename U , typename... Args>
VTK_M_DEVICE T & Emplace (std::initializer_list< U > il, Args &&... args)
 
template<vtkm::IdComponent I, typename... Args>
VTK_M_DEVICE TypeAt< I > & Emplace (Args &&... args)
 
template<vtkm::IdComponent I, typename U , typename... Args>
VTK_M_DEVICE TypeAt< I > & Emplace (std::initializer_list< U > il, Args &&... args)
 
template<vtkm::IdComponent I>
VTK_M_DEVICE TypeAt< I > & Get () noexcept
 
template<vtkm::IdComponent I>
const VTK_M_DEVICE TypeAt< I > & Get () const noexcept
 
template<typename T >
VTK_M_DEVICE T & Get () noexcept
 
template<typename T >
const VTK_M_DEVICE T & Get () const noexcept
 
template<typename Functor , typename... Args>
VTK_M_DEVICE auto CastAndCall (Functor &&f, Args &&... args) const noexcept(noexcept(f(std::declval< const TypeAt< 0 > & >(), args...)))
 
template<typename Functor , typename... Args>
VTK_M_DEVICE auto CastAndCall (Functor &&f, Args &&... args) noexcept(noexcept(f(std::declval< TypeAt< 0 > & >(), args...)))
 
VTK_M_DEVICE void Reset () noexcept
 Destroys any object the Variant is holding and sets the Variant to an invalid state. More...
 

Static Public Member Functions

template<typename T >
static constexpr VTK_M_DEVICE vtkm::IdComponent GetIndexOf ()
 Returns the index for the given type (or -1 if that type is not in the list). More...
 
template<typename T >
static constexpr VTK_M_DEVICE bool GetCanStore ()
 Returns whether the given type can be respresented in this Variant. More...
 

Static Public Attributes

static constexpr vtkm::IdComponent NumberOfTypes = vtkm::IdComponent{ sizeof...(Ts) }
 The number of types representable by this Variant. More...
 

Private Types

using Superclass = detail::VariantConstructorImpl< Variant< Ts... > >
 
using CheckTypes = vtkm::List< detail::VariantCheckType< Ts >... >
 

Private Member Functions

template<typename T , vtkm::IdComponent I, typename... Args>
VTK_M_DEVICE T & EmplaceImpl (Args &&... args)
 
template<typename T , vtkm::IdComponent I, typename U , typename... Args>
VTK_M_DEVICE T & EmplaceImpl (std::initializer_list< U > il, Args &&... args)
 
template<typename T >
VTK_M_DEVICE T & GetImpl (std::true_type)
 
template<typename T >
const VTK_M_DEVICE T & GetImpl (std::true_type) const
 
template<typename T >
VTK_M_DEVICE T & GetImpl (std::false_type) const
 

Member Typedef Documentation

◆ CanStore

template<typename... Ts>
template<typename T >
using vtkm::VTK_M_NAMESPACE::Variant< Ts >::CanStore = std::integral_constant<bool, (IndexOf<T>::value >= 0)>

Type that indicates whether another type can be stored in this Variant.

If this templated type resolves to std::true_type, then the provided T can be represented in this Variant. Otherwise, the type resolves to std::false_type.

◆ CheckTypes

template<typename... Ts>
using vtkm::VTK_M_NAMESPACE::Variant< Ts >::CheckTypes = vtkm::List<detail::VariantCheckType<Ts>...>
private

◆ IndexOf

template<typename... Ts>
template<typename T >
using vtkm::VTK_M_NAMESPACE::Variant< Ts >::IndexOf = vtkm::ListIndexOf<vtkm::List<Ts...>, T>

Type that converts to a std::integral_constant containing the index of the given type (or -1 if that type is not in the list).

◆ Superclass

template<typename... Ts>
using vtkm::VTK_M_NAMESPACE::Variant< Ts >::Superclass = detail::VariantConstructorImpl<Variant<Ts...> >
private

◆ TypeAt

template<typename... Ts>
template<vtkm::IdComponent Index>
using vtkm::VTK_M_NAMESPACE::Variant< Ts >::TypeAt = typename vtkm::ListAt<vtkm::List<Ts...>, Index>

Type that converts to the type at the given index.

Constructor & Destructor Documentation

◆ Variant() [1/4]

template<typename... Ts>
vtkm::VTK_M_NAMESPACE::Variant< Ts >::Variant ( )
default

◆ ~Variant()

template<typename... Ts>
vtkm::VTK_M_NAMESPACE::Variant< Ts >::~Variant ( )
default

◆ Variant() [2/4]

template<typename... Ts>
vtkm::VTK_M_NAMESPACE::Variant< Ts >::Variant ( const Variant< Ts > &  )
default

◆ Variant() [3/4]

template<typename... Ts>
vtkm::VTK_M_NAMESPACE::Variant< Ts >::Variant ( Variant< Ts > &&  )
default

◆ Variant() [4/4]

template<typename... Ts>
template<typename T >
VTK_M_DEVICE vtkm::VTK_M_NAMESPACE::Variant< Ts >::Variant ( const T &  src)
inlinenoexcept

Member Function Documentation

◆ CastAndCall() [1/2]

template<typename... Ts>
template<typename Functor , typename... Args>
VTK_M_DEVICE auto vtkm::VTK_M_NAMESPACE::Variant< Ts >::CastAndCall ( Functor &&  f,
Args &&...  args 
) const
inlinenoexcept

Given a functor object, calls the functor with the contained object cast to the appropriate type. If extra args are given, then those are also passed to the functor after the cast object. If the functor returns a value, that value is returned from CastAndCall.

The results are undefined if the Variant is not valid.

◆ CastAndCall() [2/2]

template<typename... Ts>
template<typename Functor , typename... Args>
VTK_M_DEVICE auto vtkm::VTK_M_NAMESPACE::Variant< Ts >::CastAndCall ( Functor &&  f,
Args &&...  args 
)
inlinenoexcept

Given a functor object, calls the functor with the contained object cast to the appropriate type. If extra args are given, then those are also passed to the functor after the cast object. If the functor returns a value, that value is returned from CastAndCall.

The results are undefined if the Variant is not valid.

◆ Emplace() [1/4]

template<typename... Ts>
template<typename T , typename... Args>
VTK_M_DEVICE T& vtkm::VTK_M_NAMESPACE::Variant< Ts >::Emplace ( Args &&...  args)
inline

◆ Emplace() [2/4]

template<typename... Ts>
template<vtkm::IdComponent I, typename... Args>
VTK_M_DEVICE TypeAt<I>& vtkm::VTK_M_NAMESPACE::Variant< Ts >::Emplace ( Args &&...  args)
inline

◆ Emplace() [3/4]

template<typename... Ts>
template<typename T , typename U , typename... Args>
VTK_M_DEVICE T& vtkm::VTK_M_NAMESPACE::Variant< Ts >::Emplace ( std::initializer_list< U >  il,
Args &&...  args 
)
inline

◆ Emplace() [4/4]

template<typename... Ts>
template<vtkm::IdComponent I, typename U , typename... Args>
VTK_M_DEVICE TypeAt<I>& vtkm::VTK_M_NAMESPACE::Variant< Ts >::Emplace ( std::initializer_list< U >  il,
Args &&...  args 
)
inline

◆ EmplaceImpl() [1/2]

template<typename... Ts>
template<typename T , vtkm::IdComponent I, typename... Args>
VTK_M_DEVICE T& vtkm::VTK_M_NAMESPACE::Variant< Ts >::EmplaceImpl ( Args &&...  args)
inlineprivate

◆ EmplaceImpl() [2/2]

template<typename... Ts>
template<typename T , vtkm::IdComponent I, typename U , typename... Args>
VTK_M_DEVICE T& vtkm::VTK_M_NAMESPACE::Variant< Ts >::EmplaceImpl ( std::initializer_list< U >  il,
Args &&...  args 
)
inlineprivate

◆ Get() [1/4]

template<typename... Ts>
template<vtkm::IdComponent I>
const VTK_M_DEVICE TypeAt<I>& vtkm::VTK_M_NAMESPACE::Variant< Ts >::Get ( ) const
inlinenoexcept

Returns the value as the type at the given index. The behavior is undefined if the variant does not contain the value at the given index.

◆ Get() [2/4]

template<typename... Ts>
template<typename T >
const VTK_M_DEVICE T& vtkm::VTK_M_NAMESPACE::Variant< Ts >::Get ( ) const
inlinenoexcept

Returns the value as the given type. The behavior is undefined if the variant does not contain a value of the given type.

◆ Get() [3/4]

template<typename... Ts>
template<vtkm::IdComponent I>
VTK_M_DEVICE TypeAt<I>& vtkm::VTK_M_NAMESPACE::Variant< Ts >::Get ( )
inlinenoexcept

Returns the value as the type at the given index. The behavior is undefined if the variant does not contain the value at the given index.

◆ Get() [4/4]

template<typename... Ts>
template<typename T >
VTK_M_DEVICE T& vtkm::VTK_M_NAMESPACE::Variant< Ts >::Get ( )
inlinenoexcept

Returns the value as the given type. The behavior is undefined if the variant does not contain a value of the given type.

◆ GetCanStore()

template<typename... Ts>
template<typename T >
static constexpr VTK_M_DEVICE bool vtkm::VTK_M_NAMESPACE::Variant< Ts >::GetCanStore ( )
inlinestaticconstexpr

Returns whether the given type can be respresented in this Variant.

◆ GetImpl() [1/3]

template<typename... Ts>
template<typename T >
VTK_M_DEVICE T& vtkm::VTK_M_NAMESPACE::Variant< Ts >::GetImpl ( std::false_type  ) const
inlineprivate

◆ GetImpl() [2/3]

template<typename... Ts>
template<typename T >
VTK_M_DEVICE T& vtkm::VTK_M_NAMESPACE::Variant< Ts >::GetImpl ( std::true_type  )
inlineprivate

◆ GetImpl() [3/3]

template<typename... Ts>
template<typename T >
const VTK_M_DEVICE T& vtkm::VTK_M_NAMESPACE::Variant< Ts >::GetImpl ( std::true_type  ) const
inlineprivate

◆ GetIndex()

template<typename... Ts>
VTK_M_DEVICE vtkm::IdComponent vtkm::VTK_M_NAMESPACE::Variant< Ts >::GetIndex ( ) const
inlinenoexcept

Returns the index of the type of object this variant is storing.

If no object is currently stored (i.e. the Variant is invalid), an invalid is returned.

◆ GetIndexOf()

template<typename... Ts>
template<typename T >
static constexpr VTK_M_DEVICE vtkm::IdComponent vtkm::VTK_M_NAMESPACE::Variant< Ts >::GetIndexOf ( )
inlinestaticconstexpr

Returns the index for the given type (or -1 if that type is not in the list).

◆ IsType()

template<typename... Ts>
template<typename T >
VTK_M_DEVICE bool vtkm::VTK_M_NAMESPACE::Variant< Ts >::IsType ( ) const
inline

Returns true if this Variant stores the given type.

◆ IsValid()

template<typename... Ts>
VTK_M_DEVICE bool vtkm::VTK_M_NAMESPACE::Variant< Ts >::IsValid ( ) const
inlinenoexcept

Returns true if this Variant is storing an object from one of the types in the template list, false otherwise.

Note that if this Variant was not initialized with an object, the result of IsValid is undefined. The Variant could report itself as validly containing an object that is trivially constructed.

◆ operator=() [1/3]

template<typename... Ts>
template<typename T >
VTK_M_DEVICE Variant& vtkm::VTK_M_NAMESPACE::Variant< Ts >::operator= ( const T &  src)
inline

◆ operator=() [2/3]

template<typename... Ts>
Variant& vtkm::VTK_M_NAMESPACE::Variant< Ts >::operator= ( const Variant< Ts > &  )
default

◆ operator=() [3/3]

template<typename... Ts>
Variant& vtkm::VTK_M_NAMESPACE::Variant< Ts >::operator= ( Variant< Ts > &&  )
default

◆ Reset()

template<typename... Ts>
VTK_M_DEVICE void vtkm::VTK_M_NAMESPACE::Variant< Ts >::Reset ( )
inlinenoexcept

Destroys any object the Variant is holding and sets the Variant to an invalid state.

This method is not thread safe.

Member Data Documentation

◆ NumberOfTypes

template<typename... Ts>
constexpr vtkm::IdComponent vtkm::VTK_M_NAMESPACE::Variant< Ts >::NumberOfTypes = vtkm::IdComponent{ sizeof...(Ts) }
staticconstexpr

The number of types representable by this Variant.


The documentation for this class was generated from the following file: