From Jason Turner
Watch on YouTube

Summary

This episode explains why attempting to move from a const object in C++ silently falls back to copying instead. Jason demonstrates that using std::move on a const object produces a const r-value reference, which cannot bind to the non-const r-value reference parameter of a move constructor. Through code examples in Compiler Explorer, he shows how move operations are skipped in favor of copy operations when the source is const, and how this behavior can be detected with tools like Clang's static analyzer.

Resources

Tags