What is copy elision and how does it optimize the copy-and-swap idiom?
The copy constructor exists to make copies. In theory when you write a line like: CLASS c(foo()); The compiler would have to call the copy constructor to copy the return of foo() into c. Copy elision is a technique to skip calling the copy constructor so as not to pay for the overhead. For example, … Read more