Search code examples
c++language-lawyerc++17semanticsvalue-categories

Why does it use the term "object" here when mentioning a prvalue?


As far as I know,in c++17 the concept/semantic of prvalue is no longer temporary object,so in many circumstances the copy elision is mandated.

However, today I came cross a description of return expression

If expression is a prvalue, the object returned by the function is initialized directly by that expression. This does not involve a copy or move constructor when the types match

Why does the term object occurs here? In value category the return of function which is not a reference type belongs to prvalue,so I think maybe it is inappropriate to use the term object.

According to my understanding,the prvalues are no longer objects now,they are just values,am I right?

As a supplement,here also use the term "object".


Solution

  • I agree with what you say. There is a discussion page on cppreference where you can raise your concerns. A better way to phrase it might be

    If expression is a prvalue, the result object of the expression is initialized directly by that expression.

    As you say, objects are no longer returned or passed around by prvalues.