|
Boost : |
Subject: Re: [boost] [outcome] Second high level summary of review feedback accepted so far
From: Peter Dimov (lists_at_[hidden])
Date: 2017-05-30 23:19:08
Andrzej Krzemienski wrote:
> > To expand on that a bit:
> >
> > T* operator->() const noexcept;
> > Requires: get() != nullptr.
> > Returns: get().
> >
> > Narrow, a mistake.
> >
>
> You say, you do not like the above, right? You call this mistake *only*
> because of this LWG guideline?
For shared_ptr, it is a mistake, period. The function does not require get()
!= nullptr in order to do its job, so it should not have a precondition. {
return get(); } is fine.
> > T* operator->() const noexcept;
> > Returns: get().
> >
> > Wide, as it should have been.
>
> You say, you like the above, right? But what does it mean? That it returns
> a `(T*)nullptr` ?
For shared_ptr, it just returns the pointer. For result<>, yes, it would
return a nullptr when no T is present, not an invalid pointer value.
> This is the same as your value_if?
Yes, as I wrote,
> > All that said, I'm actually not opposed to outcome<T>::op-> being the
> > second above (the equivalent of value_if) and op* being effectively
> > *operator->().
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk