Get lvalue through rvalue
I do not know how in the following code, rvalue -- return of X(),
could result in a lvalue finally and binded to a non-const reference
input parameter of function f.
thanks in advance,
Re: Get lvalue through rvalue
> I do not know how in the following code, rvalue -- return of X(),
> could result in a lvalue finally and binded to a non-const reference
> input parameter of function f.
You're confusing the return type of 'X()' and the full expression
that you can see inside the parentheses where 'f' is called.
> Any ideas?
The trick here is based on the fact that every temporary of a class
type is a separate object, for which you can call member functions.
The operator= is a member function. What is its usual signature?
Rewrite the expression
f( X() = X() )
in terms of member function calls, and you will hopefully see how
an r-value can be turned into an l-value.
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
|All times are GMT. The time now is 03:04 AM.|
Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.