Can anyone explain C++ exception specifications to me?

前端 未结 5 1515
野趣味
野趣味 2021-02-07 21:24

Can anyone explain Exception Specifications as used in C++ ?

  • When are they used (I have rarely seen it used in code)
  • What are the pros and cons (benefits/
5条回答
  •  猫巷女王i
    2021-02-07 22:03

    Basically, exception specifications allow the compiler to optimize the stack. The disadvantage is that it's a hell of a lot of extra spec. This means that you commonly see it in library work but not so much in working code.

    I believe there's also some compile-time exception-safety thing going on, but since I've never used it, I can't be sure.

提交回复
热议问题