Boost logo

Boost :

Subject: Re: [boost] [optional] Why was optional<T>::reset() deprecated?
From: Vicente J. Botet Escriba (vicente.botet_at_[hidden])
Date: 2016-03-04 14:15:27


Le 04/03/2016 03:14, Gavin Lambert a écrit :
> 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"?
>
[2] pretends to have a single name for all. But need some customization :(
> 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.)
>
I agree those cases are not very common, but it is not easy to argument
that they can be ignored.

Vicente

[2]
<https://github.com/viboes/std-make/blob/master/doc/proposal/factories/DXXXX_factories.md>


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