On 6/27/19 9:47 AM, Andrey Semashev via Boost wrote:
On 6/27/19 7:32 PM, Robert Ramey via Boost wrote:
On 6/27/19 8:43 AM, Andrey Semashev via Boost wrote: - From the caller's perspective, a noexcept function will never throw.
In anycase I should have phrased the above as:
Is swap guaranteed to succeed?
In general, no. It is only guaranteed to succeed if it is noexcept. See above when it is noexcept.
A... - I'm still confused. How can one say that swap is guaranteed to succeed when it can result in calling terminate()?
First, people normally don't write noexcept functions knowing they might throw.
Right - but swap is a templated function. The obvious way to implement swap is via moves on type T. So how could swap be guaranteed to succeed for any T? Meaning that the call to terminate() is equivalent to a bug. LOL - right - I'm trying to figure out how to guarantee that my program doesn't have a bug.
Second, your code after a noexcept swap() returns will not be run if terminate() gets called.
Meaning that the code is guaranteed to only operate when swap() successfully returned. LOL - I get this. The question is: how can one know that swap will be successfully returned? for a given type T.
In other words, how can it make sense that swap<T> be noexcept without considering the specific type T? Robert Ramey
_______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost