I have a function
class A { <has copy and move constructors > };
void f(A &&a) { ... }
I want to call the function f with a variable x, but I want to run f on a copy of x, not x itself. Why can't I do something like this?
f(copy(x));
But instead must do
f(A(x));
Is there anything similar to the copy function I describe above?
Note: please don't tell me to add an overload f that does the copying, I want something that doesn't require an overload and is explicit (i.e. copy makes it clear to the reader that copying is done here)
Aucun commentaire:
Enregistrer un commentaire