Usage of try/catch blocks in C++

后端 未结 8 2025
有刺的猬
有刺的猬 2020-12-08 12:01

In general, I tend to use try/catch for code which has multiple failure points for which the failures have a common handler.

In my experience, this is typically co

相关标签:
8条回答
  • 2020-12-08 12:34

    I found a technical report on C++ performance (pdf warning) that includes a section on exceptions. You might find it interesting. I've had coworkers who believed there was overhead on every instruction within a try/catch block, but this technical report doesn't seem to support that idea.

    0 讨论(0)
  • 2020-12-08 12:34

    Depends on a compiler. Why don't you write a simple function with a try-catch block and a similar one without it and compare the generated machine code?

    0 讨论(0)
提交回复
热议问题