Reimplementation of std::variant for GPU.
More...
#include <Variant.hpp>
Public Member Functions | |
| template<typename Q > | |
| constexpr auto | operator= (Q &&input) |
| Assign a value. More... | |
| template<typename Q > | |
| constexpr auto | get () |
| Access the unique element of the given type, if it exists. More... | |
| template<int I> | |
| constexpr auto | get () |
| Get by index. More... | |
| template<typename Q > | |
| Variant (Q &&v) | |
Reimplementation of std::variant for GPU.
Variants are conceptually similar to unions. They allow you to reuse the same region of memory to store different and type-incompatible objects at different times. Provided the lifetimes of the objects don't overlap, this is safe.
This is particularly useful for reusing __shared__ memory when GPU programming.
Although you cannot put arrays directly into Variants, you can use sp::Vec or sp::StaticTensor instead. These are preferable to bare arrays in all cases because they provide handy bounds-checking in debug builds.
|
constexpr |
Access the unique element of the given type, if it exists.
|
constexpr |
Get by index.
|
constexpr |
Assign a value.