Sunday, July 14, 2013

Is binding non-const references to temporaries the sole key feature of rvalue references?

Newsgroup: comp.lang.c++

Subject: Is binding non-const references to temporaries the sole key feature of rvalue references?

From: "K. Frank" <kfrank29.c@...>

Date: Sun, 14 Jul 2013 08:22:16 -0700 (PDT)



Hello Group!



Is the ability to bind a non-const reference to a

temporary the only important feature / benefit of

rvalue references?



Please note, I am not asking what it is that rvalue

references let you do; I am asking what specific

capability of rvalue references lets you do those

things.



Asked another way, if we were to permit regular

non-const references to bind to temporaries (I'm not

saying we should.), would there remain any need to

introduce rvalue references into the language?



Basic illustration:



// int& nr = 1; // illegal: non-const reference to temporary

const int& cr = 2; // const reference okay

int&& rr = 3; // non-const rvalue reference okay





Thanks for any insight.





K. Frank







via Usenet Forums - Usenet Search,Free Usenet - comp.lang.c++ http://www.pocketbinaries.com/usenet-forums/showthread.php?42096-Is-binding-non-const-references-to-temporaries-the-sole-key-feature-of-rvalue-references&goto=newpost

View all the progranning help forums at:

http://www.pocketbinaries.com/usenet-forums/forumdisplay.php?128-Coding-forums

No comments:

Post a Comment