|
Boost : |
From: Yuval Ronen (ronen_yuval_at_[hidden])
Date: 2005-10-25 11:59:27
Fernando Cacciola wrote:
> So my current proposal would be:
>
> Remove direct-assignment.
> Let copy-assigment be the only way to define the wrapped value
> Add make_optional() and make_optional_ref() as shorcuts to help with
> copy-assignment
> Keep none-assignment as the only wat to clear the wrapped value.
Does this mean that construction from T is also suggested to be removed?
I assume not...
Anyway, If I'm required to write
optional<T> o = x;
...
o = optional<T>(y);
or
optional<T> o = x;
...
o = make_optional(y);
then it should be considered that this generates an additional temporary
instance of y (of type T). Direct assignment from T doesn't suffer from
this. Working around this makes me write
optional<T>(y).swap(o);
or
make_optional(y).swap(o);
which is completely different...
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk