Home What is the copy-and-swap idiom?
Reply: 0

What is the copy-and-swap idiom?

user632
1#
user632 Published in June 25, 2018, 4:00 am

What is this idiom and when should it be used? Which problems does it solve? Does the idiom change when C++11 is used?

Although it's been mentioned in many places, we didn't have any singular "what is it" question and answer, so here it is. Here is a partial list of places where it was previously mentioned:

  • What are your favorite C++ Coding Style idioms: Copy-swap
  • Copy constructor and = operator overload in C++: is a common function possible?
  • What is copy elision and how it optimizes copy-and-swap idiom
  • C++: dynamically allocating an array of objects?
You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.454205 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO