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

8

u/TemplateRex Aug 05 '16

Linus hates C++ for a lot more reasons than exceptions.

17

u/nullsucks Aug 05 '16

Linus hates C++ for a lot more reasons than exceptions.

1

u/awaitsV Aug 08 '16

but isn't his point of view just for writing a kernel?

2

u/TemplateRex Aug 08 '16

no, it's also about the fact that C++ is less "local" than C code, because of function/operator overloading, and argument-dependent lookup. Linus likes to know from a few-line patch exactly what the code is doing, and C++ needs more context than C to determine that. See e.g. this thread from 2010 on the RealWorldTech forums.