c++ - In-place function with return value -
i have function has similar behavior of this:
void process(const t& input,t& output){ if(&input==&output){ //alter output directly } else{ output=input; //deep copy //alter output } } use case 1:
t i; //fill t o; process(i,o); use case 2:
t io; //fill io process(io,io); i want change function deceleration more readable:
t process(const t& input){ //what here? } use case 1:
t i; //fill auto o = process(i); use case 2:
t io; //fill io io=process(io); question: how can imitate previous methodology of dealing in-place cases? how should implement it? need avoid deep copying when same object.
Comments
Post a Comment