16.4 — Passing and returning std::vector, and an introduction to move semantics
When we need to pass a std::vector to a function, we pass it by (const) reference so that we do not make an expensive copy of the array data. Therefore, you will probably be surprised to find that it is okay to return a std::vector by value in some cases. …