Boost logo

Boost :

Subject: Re: [boost] [variant2] Formal review
From: Emil Dotchevski (emildotchevski_at_[hidden])
Date: 2019-04-16 17:07:09

On Tue, Apr 16, 2019 at 4:19 AM Andrzej Krzemienski via Boost <
boost_at_[hidden]> wrote:
> > But we do, std::variant does in fact have checks.
> I guess you are referring to function std::visit(), which checks for
> valueless_by_exception state and if one is detected throws an exception.

I counted 20+ checks, but actually even if the runtime cost was zero, the
empty state is one more thing the user has to think about, one more thing
that could go wrong -- but only in the context of error handling where
writing unit tests, debugging and QA are all extra difficult.

> Indeed, in the model that I am presenting, this is a useless check.

The world without the basic guarantee and without checks does not exist.
The user will be finding bugs, sooner or later he'll be calling functions
when he shouldn't, and he'll add the checks that you say he doesn't need.

That said, I agree that the checks are lame. If I say variant<A,B> and you
say but you also have to deal with C, I'd say the design is broken.

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