问题
I think exception strong
means that the program either ends successfully or if it doesn't ends successfully it leaves the data unchanged, but I am not sure what exception neutral
means. Can someone define these two terms?
回答1:
From "Exception-Safety in Generic Components":
The strong guarantee: that the operation has either completed successfully or thrown an exception, leaving the program state exactly as it was before the operation started.
and
In a generic component, we usually have an additional expectation of exception-neutrality, which means that exceptions thrown by a component's type parameters should be propagated, unchanged, to the component's caller.
回答2:
"Exception neutral" means that you don't catch all exceptions, but you catch only specific exceptions, leaving the other exceptions to propagate (to the higher levels of the application).
See http://gcc.gnu.org/onlinedocs/libstdc++/manual/using_exceptions.html for more information.
You may also want to have a look at Abrahams' exceptions safety levels: http://en.wikipedia.org/wiki/Exception_guarantees
来源:https://stackoverflow.com/questions/16770012/what-the-terms-exception-strong-and-exception-neutral-mean