Reputation: 4411
The following is valid c++
void g() {}
void (&&r)(void) = g;
See "Can an rvalue reference bind to a function?" thread for details.
My question is: What is the reason that made this possible?
Upvotes: 2
Views: 172
Reputation: 283971
I suspect that it is to provide consistency between plain functions and function objects (including lambdas).
If you make a copy of a pointer or reference to a plain function, the state (static
locals) is shared, which is somewhat the same as moving (leaving the old copy in an indeterminate but valid state).
Upvotes: 2