Is there a trick/cast letting me do that?
#include <vector>
std::vector<int> getBar(){
std::vector<int> bar (5,200); // five ints with a value of 200
return bar;
}
int main ()
{
std::vector<int> foo (3,100); // three ints with a value of 100
foo.swap(getBar());
return 0;
}
In this specific case
foo = getBar();
is a good answer. I wonder if there is a way to accomplish that task for functions other than swap taking a non const reference.