std::visit is everything wrong with modern C++: Sum Types and You

std::visit is everything wrong with modern C++: Sum Types and You

6 years ago
ian $Q__4tgrnLN

https://bitbashing.io/std-visit.html

Let’s talk about a simple, yet powerful concept in programming: sum types.1

A sum type, also called a discriminated union, can hold one (and only one) of several types of things. For example, consider some settings in an INI-like configuration file. Let’s say that each setting must be a string, an integer, or a Boolean value. If we wanted to roll our own solution in C++, we might write something resembling

std::visit is everything wrong with modern C++: Sum Types and You

Apr 12, 2018, 7:48pm UTC
https://bitbashing.io/std-visit.html >Let’s talk about a simple, yet powerful concept in programming: sum types.1 >A sum type, also called a discriminated union, can hold one (and only one) of several types of things. For example, consider some settings in an INI-like configuration file. Let’s say that each setting must be a string, an integer, or a Boolean value. If we wanted to roll our own solution in C++, we might write something resembling