The copy-and-swap idiom in C++20

158 Views Asked by At

I found this great answer from 12 years ago that explains the copy-and-swap idiom and how to implement it in C++11 and C++03.

My question is: is this still the recommended solution or has it changed in later versions of C++? (specifically I'm currently using C++20)

1

There are 1 best solutions below

0
Abazoo On

If you need safety and comfort over performance, it is still best solution. Howard Hinnant recommends you roll your own but only if you really really know how to do it and really really need the last ounce of performance.