std::variantvalues; values = 3.14159; std::cout << values.index() << "\n"; // output: 1
std::variantIn this example, we check if the currently stored type is a string using the `get_type` function. If it is a string, we output a message. The `get_type` function is a part of the C++ standard library, which is included in the default package of most C++ compilers and development environments.values; values = "hello world"; if (values.index() == 2) { std::cout << "The stored value is a string." << "\n"; }