I have a bit confusion about this code:
struct A
{
A& bar()&&;
};
A& A::bar()&&
{
std::cout << "A::bar()&&\n";
return *this;
}
int main()
{
A{}.bar();// called by an rvalue
}
So what I understand is that bar
can be called only by a modifiable-rvalue. Until this it is OK. But how can bar
return a non-constant lvalue reference to that rvalue?
- How
bar()
binds and returns a modifiable lvalue reference to that rvalue object?
Aucun commentaire:
Enregistrer un commentaire