std::vector<int> fun() { std::vector<int> temp; for(...) { // заполняем "temp" чем-либо } return temp; } std::vector<int> testVec = fun(); or
void fun(std::vector<int>& vec) { for(...) { // заполняем "vec" чем либо } } std::vector<int> testVec; fun(testVec); How will it be better, faster and in general - how to return the container correctly?
ps I read a bunch of articles on this topic on the foreign "stack", but there all the topics are old, and I’ve already left with ++ 14 and 2016 in the yard, I would like to hear the advice and opinions of the "experts" on с++ , taking into account the new standards In general, please share your experiences.