What the terms “exception strong” and “exception neutral” mean?

懵懂的女人 提交于 2019-12-14 01:56:58

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!