Conceptual distinction – Programming (C++)

lvalue vs. rvalue

  • An lvalue is usually on the left side of an assignment and is addressable in the memory.
  • An rvalue is usually on the right side of an assignment and isn’t addressable in the memory.
int i = 42; // i is an lvalue and 42 an rvalue
int& j = i; // j is an lvalue reference

rvalue reference vs. universal reference

void f(int&& i);
// no type deduction --> rvalue reference

template<typename T>
void f(T&& t);
// type deduction --> universal reference

class vs. struct

  • The members of a class per default are private.
  • The members of a struct per default are public.