std::move — casts an lvalue to an rvalue reference, enabling move semantics.
1#include <utility>2#include <string>34std::string createString() {5 std::string s = "hello";6 return std::move(s); // Move out of s7}89// Perfect forwarding with std::move10void process(std::string&& s) {11 // Use rvalue reference12}1314std::string a = "test";15process(std::move(a)); // a is now in moved-from state
Key rules: