#include #include std::string ReturnFoo(void) { std::string x("foo"); return x; // this return might copy } int main(int argc, char **argv) { std::string a("hello"); // moves a to b std::string b = std::move(a); std::cout << "a: " << a << std::endl; std::cout << "b: " << b << std::endl; // Copy return value into b. b = std::move(ReturnFoo()); std::cout << "b: " << b << std::endl; return EXIT_SUCCESS; }