#include #include class MyType { public: MyType() {} MyType(MyType&& other) { fprintf(stderr, "move ctor\n"); } // Copy constructor is implicitly deleted. // MyType(const MyType& other) = delete; }; void ProcessMyType(MyType type) { } MyType MakeMyType(int a) { // This is here to circumvent some compiler optimizations, // to ensure that we will actually call a move constructor. if (a % 2) { MyType type; return type; } MyType type; return type; } int main(int argc, char **argv) { // MakeMyType returns an rvalue MyType. // Both lines below call our move constructor. MyType type = MakeMyType(2); ProcessMyType(MakeMyType(2)); }