std::variant<Types...>::index (3) - Linux Manuals
std::variant<Types...>::index: std::variant<Types...>::index
NAME
std::variant<Types...>::index - std::variant<Types...>::index
Synopsis
constexpr std::size_t index() const noexcept; (since C++17)
Returns the zero-based index of the alternative that is currently held by the variant.
If the variant is valueless_by_exception, returns variant_npos.
Example
// Run this code
Output:
See also
holds_alternative checks if a variant currently holds a given type
(C++17)
std::get(std::variant) reads the value of the variant given the index or the type (if the type is unique), throws on error
(C++17)