On 2014-03-19 08:59, Joseph Rushton Wakeling wrote:
On 19/03/14 00:20, Steven Schveighoffer wrote:
I think we all agree that there are some things that the compiler
simply cannot
prove are nothrow, but to be able to write useful nothrow code, we
have to paste
nothrow on there anyway.
Just to clarify my understanding here: exactly how much compiler
checking _is_ done of nothrow? Is it simply to confirm that whatever is
called by the function contains no "throw" statements (hopefully all the
way down ...), or is there more ... ?
It checks that any exceptions thrown in the function body are caught in
a try/catch, and that any functions not marked nothrow are similarly
handled in a try/catch. I believe that is all.
For templated functions, the compiler does the same to figure out if the
instantiation is nothrow. Thus a function can call a templated function
that's not marked nothrow if its body can be compiled as such.
--
Simen