What is the 'noexcept' specifier and how does it affect performance and move semantics?
Last updated
noexceptdeclares a function won't throw. If it does,std::terminateis called, and the compiler can skip exception-unwinding bookkeeping for smaller, faster code.std::vectorusesstd::move_if_noexcepton reallocation: it moves elements only if the move constructor isnoexcept, otherwise it copies to keep the strong exception guarantee.Mark move constructors
noexceptwhen they truly can't throw (destructors are implicitlynoexcept).