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

后端 未结 6 1847
终归单人心
终归单人心 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:37

    It's completely implementation dependent but many recent implementations have very little or no performance overhead when exceptions aren't thrown. In fact you are right. Correctly checking return codes from all functions in code that doesn't use exceptions can be slower then doing nothing for code using exceptions.

    Of course, you would need to measure the performance for your particular requirements to be sure.

提交回复
热议问题