I was browsing on cppreference.com recently and I happened to discover this page about std::move, a function I knew nothing about.
In this page, it is clearly stated that
Unless otherwise specified, all standard library objects that have been moved from are placed in a valid but unspecified state.
So the C++ standard doesn't guarantee anything about the content of the variable after a std::move
. The part that is bugging me though is the "Unless otherwise specified".
What I would like to know is whether compilers such as GCC or Visual C++ provide any guarantee on the content of the variable? Some quick testing with a string
in Visual Studio 2013 seemed to show that the string was always empty after the move
operation.