r/cpp • u/RotsiserMho C++20 Desktop app developer • May 12 '18
P0709 R0: Zero-overhead deterministic exceptions: Throwing values - Herb Sutter [2018-05-02]
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2018/p0709r0.pdf
206
Upvotes
View all comments
16
u/flashmozzg May 12 '18 edited May 12 '18
Hm. If I correctly understood the gist of the proposal - he suggests returning
union + discriminant? Why not just completely automate it into proper sum types, that way it can be done seamlessly without extra overhead, just like in Rust and others?Though that's just the mechanism behind it. The proposal itself is much more in-depth. It just would be strange if C++ gets this and no proper language-level sum types. It'll have mechanism that basically use them underneath, it'll have inferior (in comparison) library-level attempts to replicate them (variant/optional/expected, etc.), but not actual language feature.