Subject: Re: [boost] [optional] Why was optional<T>::reset() deprecated?
From: Andrzej Krzemienski (akrzemi1_at_[hidden])
Date: 2016-03-02 03:39:04
2016-03-02 9:20 GMT+01:00 Andrey Semashev <andrey.semashev_at_[hidden]>:
> On 2016-03-02 01: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
>> 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.
>> I got that from reading Boost mailing archives once.
> FWIW, I don't think that having support for 'none' is enough reason to
> deprecate 'reset' (same for 'is_initialized'). I know some of my colleagues
> who prefer these methods to the fancy syntax because it feels more aligned
> with other Boost and standard library components.
Agreed. This is why I have no intention of removing them. But there is also
a downside to keeping two ways to do the same thing: developers often do
not understand one another's code. I left the deprecation to encourage a
move towards one interface.
> Having 'reset' also allows not to include boost/none.hpp.
You cannot avoid including boost/none.hpp. Whenever you include
boost/optional/optional.hpp, boost/none.hpp is indirectly included.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk