NRV优化为什么需要有copy constructor才能实施?
Inside The C++ model里讲到添加一个copy constructor能触发NRV优化,但NRV大概是这样:
X bar(){
X xx;
//...
return xx;
}优化成
void bar(X &_result) {
_result.X::X();
//...直接处理_result
return;
}
优化的代码不需要copy constructor啊?请知道的解答,不胜感激!
X bar(){
X xx;
//...
return xx;
}优化成
void bar(X &_result) {
_result.X::X();
//...直接处理_result
return;
}
优化的代码不需要copy constructor啊?请知道的解答,不胜感激!
...全文


