K
K. Frank
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
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