JiaHao Xu
JiaHao Xu

Reputation: 2748

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?

Upvotes: 1

Views: 172

Answers (1)

T.C.
T.C.

Reputation: 137320

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.

Upvotes: 1

Related Questions