Applies the visitor vis (a Callable that can be called with any combination of types from the variant) to the variant held by self.
Notes Let n be (1* ... *std::variant_size_v
>), implementations usually generate a table equivalent to an (possibly multidimensional) array of n function pointers for every specialization of std::visit, which is similar to the implementation of virtual functions.
Functions visit (C++17) calls the provided functor with the arguments held by one or more variant s (function template) [edit] holds_alternative (C++17) checks if a variant currently holds a given type (function template) [edit] get(std::variant) (C++17) reads the value of the variant given the index or the type (if the type is unique), throws ...
variant::visit (C++26) Non-member functions visit(std::variant) holds_alternative get(std::variant) get_if operator==operator!=operatoroperator>=operator<=> (C++20) swap(std::variant) Helper classes monostate bad_variant_access variant_size variant_alternative hash Helper objects variant_npos [edit] Defined in ...
Applies the visitor vis to the object contained in arg. Equivalent to std::visit(std::forward(vis),value), where value is the std::variant stored in arg.
std::get(std::variant) called with an index or type that does not match the currently active alternative. std::visit called to visit a variant that is valueless_by_exception.