4 ms·
C++17 has std::variant<> and it's ubiquitous in my code. Catching your type errors at compilation time is something you don't have to give up any more after do
by pklausler 5y ago
C++17 has std::variant<> and it's ubiquitous in my code. Catching your type errors at compilation time is something you don't have to give up any more after doing your prototyping in Haskell.
- b0sk 5y agoit is very clunky though. there is no pattern matching support — you need to write non-trivial visitors to do any meaningful work and it takes the fun out of it. imo, Rust gets it right and borrows a lot of Haskell ergonomics
- pklausler 5y agoIt's easy to combine a list of per-type visitors, perhaps with an "auto" catch-all, into a single visitor for use with visit(), though. Not as fun as Haskell but a real improvement over C++14 and good enough for sum types in production C++. See struct visitors in https://github.com/llvm/llvm-project/blob/main/flang/include/flang/Common/idioms.h https://github.com/llvm/llvm-project/blob/main/flang/include...