Reading through the answer for Split a string in C++?, here, a comment says
This should be
split(s, delim, elems); return elems;
, to enable return value optimization.
The relevant piece of code is
std::vector<std::string> split(const std::string &s, char delim) {
std::vector<std::string> elems;
split(s, delim, elems);
return elems;
}
Line 3 and 4 were earlier
return split(s, delim, elems);
Can you please explain what benefit do we get by splitting that line of code?