Back to notes
std::move Is Just a Cast
- C++
- Move Semantics
Deepanshu Upadhyay
November 23, 2026 · 1 min read
One of the most common misconceptions in C++ is that std::move actually moves an object.
It doesn't.
std::move is essentially a cast that converts an expression into an rvalue (more precisely, an xvalue), allowing move constructors and move assignment operators to be selected during overload resolution.
Consider:
std::string first = "Hello";
std::string second = std::move(first);What actually happens?
std::move(first)castsfirstto an rvalue reference.- The compiler selects
std::string's move constructor. - The move constructor performs the actual transfer of resources.
Without a suitable move constructor, std::move alone won't magically move anything. A copy might happen instead.
The interesting distinction: std::move doesn't move resources. It simply tells the compiler that an object can be treated as an expiring value, making move semantics possible.
Think of it as permission to move, not the act of moving.