Interview Question

What does std::move do?

std::move is a cast that enables move-aware overload resolution.

💡 Concept ✅ Quick Revision 🧠 C++

Answer

std::move performs a cast that produces an xvalue expression; it does not move data by itself. • The resulting expression can select a move constructor or move assignment operator. • If no suitable move operation exists, copying may still occur. • Do not use an object’s previous value after moving unless its documented state permits it.

💡 C++ Example

std::string source = "hello"; std::string destination = std::move(source);

⚡ Quick Revision

std::move is a cast that enables move-aware overload resolution.