Boost logo

Boost :

From: Peter Dimov (pdimov_at_[hidden])
Date: 2005-10-17 06:08:58


Joel de Guzman wrote:

> Oh, I forgot:
> http://boost.org/libs/optional/doc/optional.html#refassign
>
> To this day, I'm still befuddled at the explanation.

What's wrong with it?

"Rebinding semantics for the assignment of initialized optional references
has been chosen to provide consistency among initialization states..."

seems pretty clear to me. Since assignment to an uninitialized optional<T&>
rebinds, so does assignment to initialized optional<>.

Consider the analogy with variant<T&, U&>. What does assignment do? Under
the "always rebind" model it rebinds. Under the "behave as a reference"
model it depends on the argument type and the current state of the variant.
It may assign to the referenced object, or it may rebind. "Always rebind"
certainly appears more consistent to the untrained eye.


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