Boost logo

Boost :

From: Fernando Cacciola (fcacciola_at_[hidden])
Date: 2003-02-24 21:32:58


"Stephen Lamb" <stevel_at_[hidden]> escribió en el mensaje
news:3E56A866.61FFE91_at_imagebuilder.com...
> I'm not absolutely sure I have the latest class optional but here goes.
>
> Why does optional not have an assignment operator which takes a value?
>
Experience shown that this question is hard to answer convincely.. :-)
The very short answer is: Because it would break its pointer-like interface
(in this case, it would break symmetry)
For the long answer go through the review were the interface and it's
implications (like the lack of direct assignmen) were discussed at length.

>
> Why is the following constructor explicit?
> template<class U>
> explicit optional ( optional<U> const& rhs )
>
> I would think that this would actually be a case where implicit copy
> construction would be welcomed.
Notice that that is a _converting_ copy constructor.
As such, it is explicit in order to prevent implicit conversions.
The regular copy ctor is not explicit.

>
>
> The version of optional I have implements operators -> and * in terms of
> the get function. The get function has a conditional that is
> unnecessary extra work for -> and *. I think that -> and * should
> either be implemented in terms of a function that doesn't have a
> conditional in it or should be implemented in place.
>
Good point! Thank you.
I'll see to fix it, _probably_ for 1.30.0.

Fernando Cacciola


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