Is nothrow / noexcept enough to say we don't have a throw guarantee?
No, this is not the correct conclusion. The no-throw guarantee does not mean that you are not throwing exceptions, it means that the operation always succeeds. A code base using an allocator that returns nullptr
on failure and indicates function failures by returning a status code doesn't quite match this up. There is also no codebase that triggers abort()
on any detected error. However, both of them are perfectly possible with the functions new(nothrow)
and noexcept
.
source to share
You will have to avoid (or handle and recover from possible failures) the following language constructs:
-
dynamic_cast
to a reference type that will throwstd::bad_cast
if the conversion fails; -
typeid
applies to the result of dereferencing a potentially null pointer that will be thrownstd::bad_typeid
And of course you will have to avoid most of the standard library. In particular, things like containers use allocators that can signal failure by throwing.
You will struggle to make sure there is no throwing around the "codebase" (if that means you mean the code for an entire program or library), since the operations that you might expect will usually be performed; they can provide the maximum guarantee.
source to share