|
|
|
|
|
by Galanwe
810 days ago
|
|
Right, I'm not trying to argue that std::variant is better than native language support. By definition, a language construct will always be easier to write and read. All I'm saying is that the current state of std::variant makes it okay enough to use type safe discriminated unions. Visit + overload is not that far away from pattern matching in terms of readability, clang does warn on non exhaustive switch cases, etc. |
|
> Does that really need to be part of the language though, or as long as you can code it, or have it in the standard library, it's fine?
And my answer is, yes. I don't consider `std::variant` a proper replacement, more like a crutch that may even be worse than not having anything at all, because its existence can be used as an argument against introducing language-level sum types in the future.