As I expected this code doesn't compile because move gives you rValue and you can't assign anything to rValue:
int a, b;
move(a) = b;
The question is why below code compiles?
string a, b;
move(a) = b;
The reason is a bit surpring, probably. The first form is the built-in assignment, and that indeed does not work on rvalue references.
The second statement is actually move(a).operator=(b). That is a function call. You can call functions on rvalues, even if the functions have somewhat unusual names.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With