KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
ยง3.10 section 9 says "non-class rvalues always have cv-unqualified types". That made me wonder... int foo() { return 5; } const int bar() { return 5; } void pass_int(int&& i) { std::cout << "rvalue\n"; } void pass_int(const int&& i) { std::cout << "const rvalue\n"; } int main() { pass_int(foo()); // prints "rvalue" pass_int(bar()); // prints "const rvalue" } According to the standard, there is no such thing as a const rvalue for non-class types, yet bar() prefers to bind to const int&& . Is this a compiler bug? EDIT: Apparently, this is also a const rvalue :) EDIT: This issue seems to be fixed in g++ 4.5.0, both lines print "rvalue" now.
Tags (comma-separated)
Save Edits
Cancel