Reputation: 396
In Effective Modern C++, item 17 (Understand special member function generation), Scott Meyers said that the generated special move member functions (move constructor and move assignment operator) perform “memberwise moves” on the non-static data members of the class.
The move operations are generated only if they’re needed, and if they are generated, they perform “memberwise moves” on the non-static data members of the class.
I tried to understand the non-static condition but I couldn't, can anyone explain to me why can't they perform that on static data members?
Upvotes: 1
Views: 163
Reputation: 16300
I think it simply referres to static members, as here:
struct A{
static int s; // static member, (not moved or copied when moving/copying an instance
int w; // non-static member
};
Upvotes: 2
Reputation: 553
Because static members are not part of the created objects from that class. Though they don't need to be moved (or copied in case of copy constructor).
Upvotes: 2