11 Feb
2016
11 Feb
'16
11:17 p.m.
On 02/11/2016 11:57 PM, Emil Dotchevski wrote:
failure, and others that do not, without giving the user a choice. Even at the language level, consider that in C++ constructors don't give you the option to return an error code, the only way for them to fail is by throwing. Why? Because that is the correct design.
True. However, there are situations where throwing exceptions is the wrong design, like continuations (e.g. future<T>::then) or asynchronous return values (e.g. Boost.Asio handlers.) For both the situations a value-or-error type, like excepted<T>, is a correct design.