std::variant
`std::variant` is a type-safe union in C++ that can hold one of several specified types at a time. It allows developers to create variables that can store different types without losing type safety, making it easier to manage complex data structures.
To use `std::variant`, you define it with a list of types, such as `std::variant<int, std::string>`. This means the variable can hold either an `int` or a `std::string`. Accessing the value requires using `std::get`, which ensures that the correct type is retrieved, preventing runtime errors associated with type mismatches.