I have a very basic question in C++. How to avoid copy when returning an object ?
Here is an example :
std::vector test(const uns
Compilers often can optimize away the extra copy for you (this is known as return value optimization). See https://isocpp.org/wiki/faq/ctors#return-by-value-optimization