In this recipe, we will learn how to ensure a move constructor and a move assignment operator never throw an exception. The C++ specification doesn't prevent a move constructor from throwing (as it was determined that such a requirement would simply be too difficult to enforce, as too many legitimate examples exist even in the standard library). However, ensuring that exceptions are not thrown should be possible in most cases. Specifically, a move usually doesn't create resources but instead transfers resources and as a result, strong exception guarantees should be possible. A good example of a move that does create a resource is std::list, which must provide a valid end() iterator even on a move.




















































