3 ms·
Yet they're both conceptually the same old thing: tagged unions. In C++ everything is just more awkward since everything is bolted on as an afterthought in the
by flohofwoe 2y ago
Yet they're both conceptually the same old thing: tagged unions.
In C++ everything is just more awkward since everything is bolted on as an afterthought in the stdlib but then lacking language syntax sugar to make its usage convenient.
E.g. the (somewhat weird looking) equivalent to Rust's match is called 'visit' in C++:
https://en.cppreference.com/w/cpp/utility/variant/visit2 https://en.cppreference.com/w/cpp/utility/variant/visit2
- zaphar 2y agoI can create tagged unions in literally any language not just C++ including Assembly. Rust having syntactic and compiler checked support for them as a foundational part of the language is a material difference in the design that differs fundamentally from C++. So the the point still stands.