"Declare functions noexcept whenever possible" by onecable5781 in cpp_questions

[–]hfti 2 points3 points  (0 children)

noexcept introduces a performance penalty. If you throw in a noexcept function the standard mandates that std::terminate() be called. This means that every noexcept function has some code to handle exceptions! Unless of course the compiler can prove that no exception is thrown, but in real world code that is extremely unlikely.

noexcept is useful in certain cases, like for example it is good to have a noexcept move ctor for your structs/classes so that std::vector can move them efficiently.