Boost logo

Boost :

Subject: Re: [boost] [outcome] How to drop the formal empty state
From: Peter Dimov (lists_at_[hidden])
Date: 2017-05-26 13:08:23


Niall Douglas wrote:

> I have been persuaded by argument here that default construction to empty
> is in fact a defect in the design. The formal empty state ought to
> *always* be explicitly constructed, and **never** occur implicitly. I have
> logged this defect to https://github.com/ned14/boost.outcome/issues/44.

I don't think I agree with that. The whole point of having a singular empty
state is to default-construct to it so that the mistake of failing to assign
to the default-constructed result/outcome can be detected. This:

result<T> function()
{
    result<T> r;

    // do things that put something into r

    return r;
}

where the "do things" part sometimes fails to put something into r.

If you don't default-construct to empty, you pretty much lose the point of
having empty.


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk