In what ways do C++ exceptions slow down code when there are no exceptions thown?

后端 未结 6 1846
终归单人心
终归单人心 2020-11-27 14:19

I have read that there is some overhead to using C++ exceptions for exception handling as opposed to, say, checking return values. I\'m only talking about overhead that is i

6条回答
  •  时光取名叫无心
    2020-11-27 14:50

    There is some overhead with exceptions (as the other answers pointed out).

    But you do not have much of a choice nowadays. Try do disable exceptions in your project, and make sure that ALL dependent code and libraries can compile and run without.

    Do they work with exceptions disabled?

    Lets assume they do! Then benchmark some cases, but note that you have to set a "disable exceptions" compile switch. Without that switch you still have the overhead - even if the code never throws exceptions.

提交回复
热议问题