What is an unnamed lvalue?

I saw in the N4268 project a concept called an “unnamed lvalue” in the section below

[Note: Temporary, unnamed lvalues ​​and unvalued lvalues. A temporary object is not a valid argument template when the corresponding parameter template has a reference type. [Example:...]]

I searched a lot, but neither stackoverflow nor google gave me an answer. I just found this post about value categories

What are rvalues, lvalues, xvalues, glvalues ​​and prvalues

But it did not help.

+5
source share
1 answer

Not all lvalue expressions have names. In fact, the wording in N4296 gives us some examples:

For a template-template that is not related to the type of the link or the type of the pointer, the value of the constant expression should not be mentioned (or for the pointer, the type should not be the address):

  • subobject (1.8),
  • temporary object (12.2),
  • string literal (2.14.5),
  • the result of typeid (5.2.8) or
  • predefined variable func (8.4.1).

In addition, cppreference value category information details lvalues:

The lvalue value is an expression that identifies a non-temporal object or non-member.

The following expressions: lvalues:

  • The name of a variable or function in the scope, regardless of type, for example std :: cin or std :: endl. Even if the type of the variable has the value rvalue reference, the expression consisting of its name is the value of the lvalue expression.

  • A function call or an overloaded operator expression if the function return function or overloaded operator is a reference to lvalue, for example std :: getline (std :: cin, str) or std :: cout <1 or str1 = str2 or ++ iter

  • Built-in pre-increment and pre-decrement, dereferencing, assignment and compound assignment, index (except for the xvalue array), member access (excluding non-static elements without reference to x values, enumeration member and non-static member functions), access to membership through a pointer to data member if the left operand is lvalue, a comma if the right operand is lvalue, ternary conditional if the second and third operands are lvalues.

  • Casting an expression to a lvalue reference type.

  • String literal

However, all this does not matter, since the scope of change is the proposal Allow constant evaluation for all arguments of the non-piggy type template .

+4
source

All Articles