Quick Q: When are copy and move operations automatically generated? -- StackOverflow

Recently on SO:

What are the rules for automatic generation of move operations?

In C++98, the C++ compiler could automatically generate copy constructor and copy assignment operator via member-wise copy, e.g.

struct X {
    std::string s;
    std::vector<int> v;
    int n;
};

The compiler automatically generates copy constructor and copy assignment operator for X, using member-wise copy.

But how do things change in C++11 with move semantics?

Are the move constructor and move assignment operator automatically generated, like copy constructors and copy assignment operators?

Are there cases in which move operations are not automatically generated?

Add a Comment

Comments are closed.

Comments (0)

There are currently no comments on this entry.