<cuda/std/variant>#

2026-10-01

2 min read time

Applies to Linux and Windows

This page documents cuda::std::variant in libhipcxx, a type-safe union that holds one of a set of types, available from C++14 onwards with constexpr support.

See the documentation of the standard header <variant>

Extensions#

  • All features are available from C++14 onwards.

  • All features are available at compile time if the different value types support it.

Restrictions#

On device no exceptions are thrown in case of a bad access.

CUDA-specific changes#

cuda::std::visit utilizes recursion instead of the usual function pointer array. This greatly improves runtime behavior, but comes at the cost of increased compile times.