Why is overloading on just one ref-qualifier not allowed?
问题 Apparently, overloading on ref-qualifiers is not allowed – this code won't compile if you remove either & or && (just the tokens, not their functions): #include <iostream> struct S { void f() & { std::cout << "Lvalue" << std::endl; } void f() && { std::cout << "Rvalue" << std::endl; } }; int main() { S s; s.f(); // prints "Lvalue" S().f(); // prints "Rvalue" } In other words, if you have two functions of the same name and type, you have to define both if you define either . I assume this is