Boost logo

Boost :

Subject: Re: [boost] variant - off topic
From: Robert Ramey (ramey_at_[hidden])
Date: 2019-04-03 22:56:03


On 4/3/19 2:58 PM, Andrzej Krzemienski via Boost wrote:

>> So - simple proposal. Require that sum types have operator= deleted.
>>
>> Robert Ramey
>>
>
> It is an interesting observation. I am not sure about the consequences,
> though.

Right - hence the motivation for my post.

It is not only assignment. I ti s also swap. STL algorithms, such
> as sort() use assignment and swap inside. The question is: should std::sort
> on variants work?

Just the kind of example I was hoping to get.

This would raise the question: Under what circumstance would one want to
do this? Of course definition of a comparison function would be
non-trivial. Or maybe this should be the red flag which says "you don't
really want to do that".

> Or because of the special properties of a variant some
> STL algorithms should break, maybe storage in containers should be
> prohibitted?

For sure, the assignment of such containers would be banned.

interestingly I could also envision storage in containers without
sorting being supported. But then as far as I know, all containers
require that the member type be assignable? So by deleting the
assignment operator - these would already be prohibited with a concept
check.

> Regards,
> &rzej;
>
> _______________________________________________
> Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
>


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