Developer knowledge network ยท moderated exchange

UnreliableCode Community

Developer Research, Reverse Engineering & Coding Community

Knowledge indexLive
4Categories
919Threads
2.8KPosts
Discussion

Why std::move does not actually move anything and how rvalue references work under the hood [StackOverflow Architecture Guide]

cpp_concurrency_guru
C++ Standards Expert
MEMBER
Rep: 47
Join Date: Feb 2018
Posts: 17
Thanks: 75
1 months ago ยท Jul 3, 2026 2:57 AM
#1

A common misconception for developers coming from other languages is that std::move(x) performs a memory copy or resets the object.

In reality, std::move is just a static_cast to an rvalue reference (static_cast<T&&>(x)). It produces no machine code instructions whatsoever at runtime!

CPP
template <typename T>
constexpr std::remove_reference_t<T>&& move(T&& t) noexcept {
    return static_cast<std::remove_reference_t<T>&&>(t);
}

The actual movement happens inside the move constructor or move assignment operator that accepts T&& by stealing internal pointers (e.g. pData = other.pData; other.pData = nullptr;).

modern_cpp_artisan
C++ Template Wizard
MEMBER
Rep: 124
Join Date: Jun 2019
Posts: 29
Thanks: 72
1 months ago ยท Jul 3, 2026 4:43 AM
#2

The name move is definitely misleading for beginners. Thinking of it as std::rvalue_cast makes the entire semantics click instantly.

raii_clean_coder
Modern C++ Advocate
MEMBER
Rep: 190
Join Date: Aug 2020
Posts: 20
Thanks: 22
1 months ago ยท Jul 3, 2026 12:27 PM
#3

Also worth highlighting: passing a const object to std::move silently falls back to copy construction because const T&& binds to const T&! Always watch out for const variables when trying to move.