noexcept
can dramatically improve performance of some operations. This does not happen at the level of generating machine code by the compiler, but by selecting the most effective algorithm: as others mentioned, you do this selection using function std::move_if_noexcept
. For instance, the growth of std::vector
(e.g., when we call reserve
) must provide a strong exception-safety guarantee. If it knows that T
's move constructor doesn't throw, it can just move every element. Otherwise it must copy all T
s. This has been described in detail in this post.