For example, I have a class called MyClass
and create an instance from it:
auto obj = MyClass()
I have two ways to call its method.
Option 1: call the method directly
obj.method()
Option 2: cast obj
to rvalue reference first, then call the method
std::move(obj).method()
I was wondering whether it is possible to create different implementation of method
between Option 1 and Option 2. Is there a way to route/overload the method according to whether an object is a rvalue reference or not?