Temporary as lvalue



 DEVELOP > c-Plus-Plus > Temporary as lvalue

LINK TO THIS PAGE  


rating :  0   |  0


  Page 1 of 1

1

 
Topic: DEVELOP > c-Plus-Plus
User: "Vyacheslav Kononenko"
Date: 14 Dec 2006 09:18:47 PM
Object: Temporary as lvalue
I found out that recent MS VS (maybe elder too) treats temporary to
user types as lvalue or allows conversion. So something like this would
compile there:
//-----------------
struct Bar{};
void foo( Bar & );
void f() { foo( Bar() ); }
//-----------------
Are they moving towards new standard or it is their own initiative?
Thanks,
Vyacheslav
.

User: "John Carson"

Title: Re: Temporary as lvalue 15 Dec 2006 12:06:15 AM
"Vyacheslav Kononenko" <vyacheslav@kononenko.net> wrote in message
news:1166152727.134982.135820@l12g2000cwl.googlegroups.com

I found out that recent MS VS (maybe elder too) treats temporary to
user types as lvalue or allows conversion. So something like this
would compile there:
//-----------------
struct Bar{};
void foo( Bar & );

void f() { foo( Bar() ); }
//-----------------
Are they moving towards new standard or it is their own initiative?

When I compile your code, it does give a warning:
warning C4239: nonstandard extension used : 'argument' : conversion from
'Bar' to 'Bar &'
A non-const reference may only be bound to an lvalue
At best, it compiles for reasons of backward compatibility. It reflects the
old, not the new.
--
John Carson
.

User: "Salt_Peter"

Title: Re: Temporary as lvalue 14 Dec 2006 11:58:43 PM
Vyacheslav Kononenko wrote:

I found out that recent MS VS (maybe elder too) treats temporary to
user types as lvalue or allows conversion. So something like this would
compile there:
//-----------------
struct Bar{};
void foo( Bar & );

void f() { foo( Bar() ); }
//-----------------
Are they moving towards new standard or it is their own initiative?

Thanks,
Vyacheslav

Have you tried disabling MS extensions with /Za ?
.


  Page 1 of 1

1

 


Related Articles
 

NEWER

pg.1232     pg.940     pg.716     pg.544     pg.412     pg.311     pg.234     pg.175     pg.130     pg.96     pg.70     pg.50     pg.35     pg.24     pg.16     pg.10     pg.6     pg.3     pg.1

OLDER