std::variant is a type-safe union in C++17 and later, which can hold an object of one
of several types, but only one type at a time. The type of the contained object can
be checked at runtime, and a specific type can be extracted from the variant. 
The variant type is defined by specifying a set of possible types as its template 
arguments. For example:


std::variant<int, double, std::string> value;
value = 42;
value = 3.14;
value = "Hello";

In this example, value can hold an int, a double, or a std::string, but only one
type at a time. The type of the contained object can be checked at runtime using the
std::holds_alternative function and the contained value can be extracted using the 
std::get function.

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: