0

The below is a toy program I wrote to ask my question.

class Yo2 {
 public:
  Yo2() {}
  void foo2() && {}
};

void tmp(Yo2&& yo2) {
  yo2.foo2();
}

My compiler says

'this' argument to member function 'foo2' is an lvalue, but function has rvalue ref-qualifier

What am I missing? Why is yo2 being considered an lvalue?

claudius
  • 1,112
  • 1
  • 10
  • 23
  • https://stackoverflow.com/questions/5481539/what-does-t-double-ampersand-mean-in-c11 – yo1nk Apr 15 '22 at 01:17
  • All variables are l-values. `yo2` is a r-value reference, but `yo2` itself is l-value. – 273K Apr 15 '22 at 01:20
  • Sorry @273K, I didn't understand your answer. You need to dumb it down to C++ noobs like me :-) What's the difference between r-value and r-value reference? – claudius Apr 15 '22 at 01:25

0 Answers0