Benefits of a swap function?

For most classes, the default swap is fine, however, the default swap is not optimal in all cases. The most common example of this would be a class using the Pointer to Implementation idiom. Where as with the default swap a large amount of memory would get copied, is you specialized swap, you could speed it up significantly by only swapping the pointers.

If possible, it shouldn’t be a friend of the class, however it may need to access private data (for example, the raw pointers) which you class probably doesn’t want to expose in the class API.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)