The standard doesn't enforce noexcept on move constructors. In what circumstances is it acceptable/neccesary for a move constructor to throw?
When should I declare a move constructor without noexcept?
1.5k Views Asked by Klaufir At
2
There are 2 best solutions below
3
On
When you really have no choice. Most of the time your move constructor should be noexcept. And they are by default.
It is especially important to use noexcept for types that are intended to be used with the standard library containers. If the move constructor for an element type in a container is not noexcept then the container will use the copy constructor rather than the move constructor.
The golden rule here is: It depends.
Here is an example where it might make sense: