c++c++11splicestdlistforward-list

Are std::list::splice() and std::forward_list::splice_after() declared as noexcept in C++11?


Cppreference mentions nothing about the exception guarantee of std::forward_list::splice_after() and std::list::splice().

However, since these 2 functions only change the pointer of the list node and thus do not need to copy/move any elements or allocate any memory, IMHO they should be noexcept.

Are they noexcept in C++11? If they are not, why not?


Solution

  • All but one has a "Throws: Nothing." in the standard and the one that is missing it appears to be an oversight.

    They are not noexcept because they are narrow-contract. If you break the (many) preconditions, a debug-mode implementation may want to throw an exception.