Boost logo

Boost :

Subject: Re: [boost] variant - off topic
From: Julien Blanc (julien.blanc_at_[hidden])
Date: 2019-04-04 11:36:57


Le mercredi 03 avril 2019 à 14:27 -0700, Robert Ramey via Boost a
écrit :
> I'll concede that, influenced by functional programming style, with
> a
> little experimentation with F# and propaganda from the Haskell
> community, I've become accustomed to code in the above way. Also
> I've
> become afraid to assign anything to these types. The discussion has
> made me aware of a raft of unintended consequences of doing what on
> it's
> surface seems a trivial operation. I've gotten to the point that
> assignment to a variant type, or "changing the type" of a value at
> runtime is not code smell to me. Maybe all this could be just
> eliminated if this became the accepted position.

Variants are really usefull as a container for a definite set of
messages in message queues between tasks/threads, and that usually
involves storing the last received message in a variable.

The nice thing is such variants must be variants of POD, so they don't
have the issues being discussed here.

I like the idea of simply deleting operator= : if you can't guarantee
you do something correctly, just don't do it. Optionnaly provide an
unsafe interface if it really make sense.

Regards,

Julien


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