On 27/05/2017 01:16, Niall Douglas wrote:
Outcome uses a different mitigation by restricting the possible types of
E, rendering the above case very unlikely (although not impossible,
since outcome is legal).
A static assert should prevent construction with a T convertible to or
from an error_code_extended or a std::exception_ptr. As
error_code_extended explicitly constructs from error_code,
outcome should not compile.
Sorry, I probably should have said "since *I assume* outcome
is legal".
I can imagine some scenarios where that might be useful (perhaps as part
of some error translation code which wants to return a modified value
but can also fail) but I suppose that would complicate the constructors
a bit so I can understand why it'd be disallowed, and it should be rare
enough not to really bite anyone.
(Although tagged constructors to resolve that ambiguity wouldn't be an
issue if you could only create an errored outcome with a helper like
make_unexpected...)