Boost logo

Boost :

Subject: Re: [boost] Noexcept
From: Gavin Lambert (gavinl_at_[hidden])
Date: 2017-06-13 08:28:38


On 13/06/2017 18:12, Emil Dotchevski wrote:
> In Noexcept, it is not correct to always use try_, for the same reason you
> don't always use try with exception handling. That is only used if you want
> to _handle_ errors, not just check for errors; see the second Q&A here:
> https://zajo.github.io/boost-noexcept/#qanda.
>
> Error checking with Noexcept depends on your choice of return type. For
> example, if your return type is T *, you'd check for 0, if your return type
> is shared_ptr<T> or optional<T>, you'd check using the conversion to bool.

Is it still legal to have a function return the designated error value
without actually setting an error? Perhaps sometimes returning an empty
shared_ptr is the successful return.

This in turn suggests that it's necessary to call try_ or similar to
verify the difference between success and error, assuming that it does
so using the TLS state rather than by inspecting the return value. (Or
perhaps only inspects the TLS state when the return value is the error
value, as a performance optimisation.)


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