Obviously, pimpl is not strictly necessary, but if the class is designed the "normal" way, then, it seems that moving is not going to give you the full intended benefit: moving is supposed to be cheap; in particular, it should be much faster than copying; the cost should not "scale up" with the amount of "real" internal data. Ideally, the cost should be O(1).
Obviously, if you use pimpl, you will achieve this speed benefit every time with minimal effort and maximum reliability (thanks to = default
). So, is there any reason not to just do pimpl all over the place whenever you want the ability to move an object?
(I'm assuming that you are allowed to use the heap in your application, since that obviously rules out pimpl.)