Sorry for the confusing title, and sorry if this is a duplicate (I tried searching for an answer online), hopefully this example clears it up:
Basically, would it be better to do this:
void fill(vector<int> & v);
int main() {
vector<int> v;
fill(v);
return 0;
}
or this:
vector<int> fill();
int main() {
vector<int> v = fill();
return 0;
}
I've been reading about how in C++11 the compiler will move the return results of functions rather than copying them. Is one of these better than the other? Or is it simply preference?