Does noexcept improve performance?

Theoretically speaking, noexcept would improve performance. But it might also cause some problems on the other hand.

In most of cases, it shouldn’t be specified because the pros are too few to be considered and it might make your code upgrading painful. This post, written by Andrzej, introduces the reasons in detail.

If it’s too long, just take these suggestions I conclude from it:

  1. Annotate functions with noexcept if
    • they were annotated with throw() already,
    • or they are good candidates(listed in post) and never throw for sure,
    • or they are move-constructors, move-assignments whose noexcept annotation cannot be correctly deduced by compiler and their instances are supposed to be put into some STL container.
  2. Do not annotate the functions with noexcept if
    • you are really concerned about reduced performance,
    • or about the risk of calling std::terminate,
    • or you are just not sure about the new feature,
    • or you have doubts whether you should make your function noexcept or not.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)