New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[over.match.copy]: "return lvalues or xvalues" makes me uncomfortable #2053
Comments
"Result" is defined as the value/object returned by the function call, so I don't think that's quite right. We want to say that the call expression is an lvalue or xvalue. Maybe:
? |
Strictly speaking, we don't need "therefore" in normative text. We're not arguing, we're defining rules. Just saying "A conversion function returning "reference to X" is considered to yield X for this process of selecting candidate functions." is good enough. But, we're sometimes a bit tutorial-esque in the standard, so why not here, too? |
Then the note [basic.lval]/4 needs fix? It says "An expression is an xvalue if it is: the result of calling a function, whether implicitly or explicitly, whose return type is an rvalue reference to object type" There already exists PR about [basic.lval]/4 — #2045 — so could the fix for "xvalue is ... the result of calling a function" be added into it? |
I'm inclined to call this NAD. I have no problem with "returning an xvalue"; in fact, that's how I usually say it myself when the distinctions matter. To me, this fits as follows: as a general statement that I think sounds meaningful to most programmers, regardless of language, "a function returns a value" is a useful shorthand for "the result of evaluating a function call expression is a value". Now all we're doing is extending this schema to be specific about the category of that value. Jens's change is fine (though I think we'd be OK without it, too), but I wouldn't want to consider "f returns an int lvalue" to be inappropriate language. I find it very useful and concise language. |
UPD: [over.match.copy] and [over.match.conv]
The sections [over.match.copy] and [over.match.conv] have statements like: "Conversion functions that return “reference to X” return lvalues or xvalues ..."
[diff.expr]/4 is also broken: "C++ is an object-oriented language, placing relatively more emphasis on lvalues. For example, functions may return lvalues."
"return value category" sounds illiterate for me.
Proposed wording:
The text was updated successfully, but these errors were encountered: