c++c++11typesvalue-categories

What are "names which are not lvalues"?


There's an entry in the errata of Effective Modern C++ which says that

not all names are lvalues

What are these names? Specifically,

  1. is Scott just referring to the nullptr and this named prvalues?
  2. Are there any others?
  3. In case the answer to 1 is yes, then what makes nullptr special with respect to true and false? They are all values of some type (true/false of type bool, nullptr of type std::nullptr_t). After all true stays to bool just like 1 stays to int, and 1 is not a "name which is not an lvalue", is it? At this point I'd ask why is true not a name then?

Solution

  • An expression X where X is the name of an enumerator (declared e.g. as enum E { X };) has rvalue value category.


    Similarly for non-type template parameters (hat tip to @PasserBy), as in

    template <int X>
    int f() { return X; /* X is an rvalue */}