std::vector<float> someOp(void)
{
using namespace std;
vector<float> results;
// some operations done to results
return results;
}
int main(void)
{
using namespace std;
vector<float> &results = someOp();
}
Does the vector returned by someOp exist in the someOp() stack space or in the main() stack space?
I'm inclined to believe that it doesn't get copied/moved to the main() stack space since the results vector has the same address inside of both methods.
Neither, that's not valid C++ (and doesn't get compiled by g++).
It seems you're trying to store a reference to the returned results, but that's impossible as the returned results exists in the stack frame of someOp, and, while it will still be there just after someOp() returns, will get overwritten at some point in the future.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With