Boost logo

Boost :

Subject: Re: [boost] [optional] Why was optional<T>::reset() deprecated?
From: Gavin Lambert (gavinl_at_[hidden])
Date: 2016-03-03 21:14:13


On 2/03/2016 11:51, Andrzej Krzemienski wrote:
> At some earlier stages of development, boost::optional did not have the
> assignment from boost::none_t (and probably also from T); and reset was the
> only way to efficiently change the optional from the state of having the
> value to the state of not having the value.
>
> After the addition of more fancy syntax (conversion to bool, assignment
> from none_t), reset() (and is_initialized()) became redundant, and hence
> the deprecation.

It still bothers me a bit that none and nullptr are separate. Do we
really need two different ways to spell "nothing"?

I suppose there is a use case for optional<some-pointer-type> which
could have distinct states for "no pointer" vs. "null pointer" vs.
"valid pointer", but how often do you really need to distinguish the
first two states?

(Although I guess if you didn't want to distinguish them, you'd just use
some-pointer-type directly instead of wrapping it in an optional. So I
understand the presumed rationale, it just seems weird.)


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