Question.3
A factory function returns a Buffer by value:
Buffer create_buffer(int n) { Buffer b(n); return b; // Copy or move? } Buffer buf = create_buffer(64);
How many copies are made?
Select Answer
Two copies -- one to return, one to initialize buf
One copy -- the return value is copied into buf
Zero copies -- modern compilers apply RVO (Return Value Optimization), constructing the object directly in buf
Depends on whether the copy constructor is deleted