Before shrink to fit, you could easily have produced this with a few references and a &quot;use std::swap unconditionally&quot;.<p>The std::swap thing is only one pitfall, the reliance on &quot;our memcpy will do the right thing with <i>any</i> overlap&quot; is a bit risky (and doesn&#x27;t hold with LD_PRELOAD, but I think it may have been switched to using the LLVM based librt project anyway, that is I&#x27;m not sure these calls are supposed to become <i>naked</i> memcpy).