I am grabbing this code from cppreference.com and cannot understand why std::forward is used sometimes on the callable and sometimes it isn't...
The Callable is named f and it is never forwarded in the above. f is a pointer-to-member and t1 is the first argument to the Callable.
t1 is forwarded whenever its value category could affect the behavior of the INVOKE operation.
It's forwarded unless the parameter t1 is a reference to reference_wrapper. In that case t1 is the implicit object argument to std::reference_wrapper<T>::get. And there t1.get() is always an lvalue expression with type T, no matter T, no matter the value category of t1, and no matter any template specializations. So there's no need to forward it.
[output]
t1 is forwarded whenever its value category could affect the behavior of the INVOKE operation.
[/output/
this would be the case when T1 provides 2 implementations of the function whose only difference is that one is called for lvalue reference and the other for rvalue reference?
lik this:
1 2 3 4 5
struct T1
{
int DoSomething() & { return 12; }
int DoSomething() && { return 22; }
}
Essentially, although the "function" being called (the Callable) is f, not t1, it's still possible to make a t1 where value category makes a difference.