std::variant was added in C++17 to support the sum type. It adds more functionality to union and hence is a safer version of it.
Sum types and product types
A type defines the set of values and the permissible operations on those values. For example it might make sense to concatenate two strings.
Types are usually classified into different typeclasses such as enumerable, comparable etc. The types of our interest are composite types that have sum type and product type.
The Sum types like T1+T2 co...
Published on March 03, 2021 01:45