Boost logo

Boost :

Subject: Re: [boost] expected/result/etc
From: Emil Dotchevski (emildotchevski_at_[hidden])
Date: 2016-02-13 01:08:28

On Fri, Feb 12, 2016 at 9:53 PM, Michael Marcin <mike.marcin_at_[hidden]>

> On 2/12/2016 11:36 PM, Emil Dotchevski wrote:
>> Let's say in your example, the function throws 50% of the times you call
>> it. Assuming this isn't an anomaly, it means that you're not really
>> throwing to indicate a failure, but to report a result. Obviously that's
>> not a good design.
> And this is exactly the sort of situation I would want to use result<T> in
> instead of throwing an exception.
> I want discriminated union type that is optimized in interface and
> implementation specifically for transporting a T or an error code.
> And, if in the design a choice must be made, favors T slightly.

If your point is that in case a function "fails" 50% of the times it's
called, one should not be throwing an exception to discriminate between
success and failure, I agree; OTOH in this case the "error code" vocabulary
doesn't seem appropriate.


Boost list run by bdawes at, gregod at, cpdaniel at, john at