What is the 'noexcept' specifier and how does it affect performance and move semantics?

Last updated 21 June 2026

  • noexcept declares a function won't throw. If it does, std::terminate is called, and the compiler can skip exception-unwinding bookkeeping for smaller, faster code.

  • std::vector uses std::move_if_noexcept on reallocation: it moves elements only if the move constructor is noexcept, otherwise it copies to keep the strong exception guarantee.

  • Mark move constructors noexcept when they truly can't throw (destructors are implicitly noexcept).

  • https://www.geeksforgeeks.org/cpp/noexcept-specifier-in-cpp-17/
  • https://www.geeksforgeeks.org/cpp/noexcept-operator-in-cpp-11/
  • https://www.geeksforgeeks.org/cpp/move-constructors-in-c-with-examples/
  • https://stackoverflow.com/questions/8001823/how-to-enforce-move-semantics-when-a-vector-grows
All C++ interview questions