I have a function that has a 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 i
T o;
process(i,o);
Use case 2:
T io;
//fill io
process(io,io);
I want to change this function deceleration to be more readable:
T process(const T& input){
//What to do here?
}
Use case 1:
T i;
//fill i
auto o = process(i);
Use case 2:
T io;
//fill io
io=process(io);
Question: How can I imitate the previous methodology of dealing with in-place cases? How should I implement it? I need to avoid deep copying when it is the same object.