#include #include #include class MyType { public: MyType() {} MyType(const MyType& other) { fprintf(stderr, "copy!\n"); } MyType(MyType&& other) { fprintf(stderr, "move!\n"); } }; void ProcessMyType(MyType type) {} MyType MakeMyType(int a) { if (a % 2) { MyType type; return type; } MyType type; return type; } int main(int argc, char** argv) { const MyType type = MakeMyType(2); // std::move casts to an rvalue, but since this is const, it becomes an rvalue // to const, which uses the copy constructor, not the move constructor. ProcessMyType(std::move(type)); }