std::variant::index (3) Linux Manual Page
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 #include <variant> #include <string> #include <iostream> int main() { std::variant<int, std::string> v = "abc"; std::cout << "v.index =…
