Boost logo

Boost :

Subject: Re: [boost] Strong guarantee variant (Was: Outcome/expected/etc/etc/etc)
From: Andrzej Krzemienski (akrzemi1_at_[hidden])
Date: 2017-06-08 13:09:49


2017-06-08 14:59 GMT+02:00 Peter Dimov via Boost <boost_at_[hidden]>:

> Andrzej Krzemienski wrote:
>
>> 2017-06-06 14:20 GMT+02:00 Peter Dimov via Boost <boost_at_[hidden]>:
>>
>> > Types don't generally provide the strong guarantee on assignment as it
>> > doesn't compose. If type T has strong assign, type U has strong assign, >
>> struct { T t; U u; } no longer does. So it's more efficient to just do >
>> basic everywhere, which does compose, and then at the specific point you >
>> want the strong guarantee, use f.ex. the copy and swap trick to get it.
>>
>>
>> I think the reasoning behind Niall's position is that a type `X` can have
>> a custom guarantee: upon its assignment it guarantees that after a throw
>> the type is either unchanged or goes to fallback state `0`. This guarantee
>> is
>>
> stronger than basic, and weaker than strong.
>
> Types _could_ provide such a guarantee, but don't, for the same reason
> they don't provide strong - as outlined in the quoted paragraph above, if
> types X and Y provide it, struct { X x; Y y; } no longer does. So it's
> additional work, and buys nothing much.
>

Yes, such guarantee is not composable when you put X into product types.
But it still could work for certain cases of assignments of variant<X, ...>
(those cases where both variants hold an X).

Personally, I have never found such guarantee useful in practice, but the
demand seems theoretically sound.

Regards,
&rzej;


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