views:

99

answers:

1

It took me quite some time to understand the difference between an rvalue and a temporary object. But now the final committee draft states on page 75:

An rvalue [...] is an xvalue, a temporary object or subobject thereof, or a value that is not associated with an object.

I can't believe my eyes. This must be an error, right?


To clarify, here is how I understand the terms:

#include <string>

void foo(std::string&& str)
{
    std::cout << str << std::endl;
}

int main()
{
    foo(std::string("hello"));
}

In this program, there are two expressions that denote the same temporary object: the prvalue std::string("hello") and the lvalue str. Expressions are not objects, but their evaluation might yield one. Specifically, the evaluation of a prvalue yields a temporary object, but a prvalue IS NOT a temporary object. Does anyone agree with me or have I gone insane? :)

A: 

Yes, i agree with you. This should be fixed in my opinion, and several people i deeply pay respect to have risen the exact same question about this.

Johannes Schaub - litb