Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Lvalue-to-rvalue conversion vs rvalue reference

11 views
Skip to first unread message

restor

unread,
Dec 22, 2009, 1:34:53 PM12/22/09
to
Hi,
3.10/7 in N3000 Says:
"Whenever an lvalue appears in a context where an rvalue is expected,
the lvalue is converted to an rvalue;"
On the other hand I was pretty sure that the following code shouldn't
compile:

void possiblyDestroy( Obj && obj );

int main() {
Obj obj;
possiblyDestroy( obj );
}

In the function call above, an rvalue is expected, "obj" is an lvalue,
so it "appears in a context where an rvalue is expected".
Is the above code valid?

Regards,
&rzej

--
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std...@netlab.cs.rpi.edu]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html ]

Johannes Schaub (litb)

unread,
Dec 22, 2009, 4:48:14 PM12/22/09
to
restor wrote:

> Hi,
> 3.10/7 in N3000 Says:
> "Whenever an lvalue appears in a context where an rvalue is expected,
> the lvalue is converted to an rvalue;"
> On the other hand I was pretty sure that the following code shouldn't
> compile:
>
> void possiblyDestroy( Obj && obj );
>
> int main() {
> Obj obj;
> possiblyDestroy( obj );
> }
>
> In the function call above, an rvalue is expected, "obj" is an lvalue,
> so it "appears in a context where an rvalue is expected".
> Is the above code valid?
>

It's invalid. See http://www.open-
std.org/jtc1/sc22/wg21/docs/cwg_active.html#964

0 new messages