Topic: Lvalue-to-rvalue conversion vs rvalue reference
Author: restor <akrzemi1@gmail.com>
Date: Tue, 22 Dec 2009 12:34:53 CST Raw View
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-c++@netlab.cs.rpi.edu]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html ]
Author: "Johannes Schaub (litb)" <schaub-johannes@web.de>
Date: Tue, 22 Dec 2009 15:48:14 CST Raw View
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
--
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@netlab.cs.rpi.edu]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html ]