Efficiently moving a class with PODs

c++, c++11

Solution

PODs don't move, they just copy. Because there's no indirection. So just use an ordinary assignment, and ask the compiler to optimize for whatever efficiency you have in mind. Remember to measure, systematically, before (what on Earth you are doing differently) and after. Also consider whether the wasted programmer time, which is money, is worth the micro-optimization.

Problem

How do I efficiently move a class with a large set of POD members? Example: ``` struct{ int a1; int a2; int a3; ... ... ... }; ``` By 'move' I mean that the behavior is similar to the move semantic (std::move).

Original source