title: What is the copy-and-swap idiom?
body: <p>What is the copy-and-swap idiom and when should it be used? What problems does it solve? Does it change for C++11?</p>
  <p>Related:</p>
  <ul>
  <li><a href="https://stackoverflow.com/questions/276173/what-are-your-favorite-c-coding-style-idioms/2034447#2034447">What are your favorite C++ Coding Style idioms:  Copy-swap</a></li>
  <li><a href="https://stackoverflow.com/questions/1734628/copy-constructor-and-operator-overload-in-c-is-a-common-function-possible/1734640#1734640">Copy constructor and = operator overload in C++: is a common function possible?</a></li>
  <li><a href="https://stackoverflow.com/questions/2143787/what-is-copy-elision-and-how-it-optimizes-copy-and-swap-idiom">What is copy elision and how it optimizes copy-and-swap idiom</a></li>
  <li><a href="https://stackoverflow.com/questions/255612/c-dynamically-allocating-an-array-of-objects/255744#255744">C++: dynamically allocating an array of objects?</a></li>
  </ul>