Can anyone explain C++ exception specifications to me?

前端 未结 5 1447
野趣味
野趣味 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条回答
  •  情歌与酒
    2021-02-07 21:55

    They are generally regarded as a bad idea.

    They say what a method will throw. The downside is that if that method throws anything else then your app terminates. So it's a guarantee but not in the same way that Java does it. And it adds the overhead of inspection.

提交回复
热议问题