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 ]
> 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