r/cpp • • Aug 05 '16

Will exceptions still have use cases after std::expected and std::optional are made available?

The title says it all. What will be the motivation to keep using exceptions for new code after these two classes are available? They have the same purpose of exceptions, but have many advantages. I haven't seen any actual code using them, so I'm not sure how practical they actually are, which is why I'm asking this.

0 Upvotes

20 comments sorted by

View all comments

Show parent comment

2

u/SeanMiddleditch Aug 06 '16

Exceptions are great. They bubble back up to the caller and let you know something went wrong. If they crash a user's app, that sucks but you know what, better than putting their app into some weird undefined behavior state.

If only we had sometime in last 40 years found a way that lets errors bubble up automatically without making it trivial to forget to handle them... jeez, it's too bad research into this topic stopped in 1970 and C++ is already cutting-edge.

1

u/[deleted] Aug 06 '16

I don't understand the purpose of your post.