So let's say i have interface:
class MyInterface
{
public:
virtual ~MyInterface() = default;
virtual void DoSomething(const MyType& a, const MyTypeB& b);
};
And the thing i want is to allow usage of move semantics if any of function arguments is rvalue or lvalue reference.
What i don't want is to define interface like this:
class MyInterface
{
public:
virtual ~MyInterface() = default;
virtual void DoSomething(const MyType& a, const MyTypeB& b);
virtual void DoSomething(MyType&& a, const MyTypeB& b);
virtual void DoSomething(const MyType& a, MyTypeB&& b);
virtual void DoSomething(MyType&& a, MyTypeB&& b);
};
And the combinatorics get even worse if more parameters added to the method.
So in implementation i basically want to move argument if i got rvalue passed and copy otherwise.
There's std::forward in the standard library, but it works with so called "forwarding reference", which require templates and it's impossible to have template parameters in virtual methods.
Is there any way to do this with preserving the purpose of interface base type and without bloating the interface itself so much?