Boost logo

Boost :

Subject: Re: [boost] [variant2] Andrzej's review -- design
From: Emil Dotchevski (emildotchevski_at_[hidden])
Date: 2019-04-06 00:46:54


On Thu, Apr 4, 2019 at 4:30 PM Gavin Lambert via Boost <
boost_at_[hidden]> wrote:
> The problem with transitioning to an otherwise valid but unexpected
> state is that it may end up evaluating unintended code

This is why I made the analogy with std::vector. Let's say you always put
exactly 10 elements in all your vectors, but then you assign one vector to
another, and that fails, and now (unexpectedly?) you have an (otherwise
valid) vector with fewer than 10 elements.

Such is life. This is how the basic guarantee works, you get an unspecified
but valid state.

> (Granted, continuing evaluation on a faulted variable is already a bug
> in itself, but you are making detection of that bug harder by not
> putting the value into an obviously-faulted state.)

I do not think that it is a bug to access an object that is in a valid
state. In fact, the reason why the state is defined as valid is so that you
can safely work with that object, even after a failure was reported.


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