If I understand correctly copy elision will happen if an object is returned like this:
CSomeObject getObject(){
//....
//....
return CSomeObject(...);
}
Is it safe to assume that copy elision will also happen here:
CSomeObject getObject(){
CSomeObject some_object;
some_object.setStuff();
some_object.setMoreStuff();
//....
//....
return some_object;
}
CSomeObject some_object = getObject();
There is only one return statement and always the same temporary object is returned. What about when the return is delegated / indirect:
CSomeObject getObject_2(){
//....
return getObject();
}
CSomeObject some_object = getObject_2();