Is this copied, or are references implicitly used?Code:vector<int> test() { vector<int> eg; [.......] return eg; } vector<int> myvec = test();
In other words, if eg turns out to have 5000 elements and I call test in a loop a few thousand times, AND eg is created and then copied each time -- this is not so good.
I was hoping the magic of ref counting would mean that I could return a reference to eg, but I guess eg is still just a local variable, so it seems the only way around this is:
Or have I misunderstood something?Code:vector<int> *test() { vector<int> *eg = new vector<int>(); return eg; }



LinkBack URL
About LinkBacks



