void f(const std::vector<int>& v) //#1
{
std::vector<int> a(v);
...
}
void f(std::vector<int>&& v) //#2
{
std::vector<int> a(std::move(v));
...
}
Is there some way to write #1 and #2 in one function without overloading but achieving the same effect? I mean, if argument is lvalue, then use copy constructor, if argument is rvalue, then use move constructor.
As you can see, if there is more than one parameter, I will need to write 2^n overloads.