| 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 ?
.
|
|
|
|

|
Related Articles |
|
|