473,395 Members | 1,948 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

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

Dec 15 '06 #1
2 3654

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 ?

Dec 15 '06 #2
"Vyacheslav Kononenko" <vy********@kononenko.netwrote in message
news:11**********************@l12g2000cwl.googlegr oups.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
Dec 15 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
by: Dave | last post by:
Hello all, The code below is not legal (problem with the foo_t initializer list) because: "A reference that is not to 'const' cannot be bound to a non-lvalue" How can I best achieve an...
19
by: Kai-Uwe Bux | last post by:
Hi folks, I have trouble writing a class, derving from stringstream, that collects item and once it's done will write them to std::cout in one go. It works fine except when I use it as a...
17
by: Henning Hasemann | last post by:
I have a function which gets the adress of an object as argument. It does some comparsion with the object's contents and then returns. no Reference or pointer to the object is stored or will be...
17
by: Klaas Vantournhout | last post by:
Hi all, I was wondering if it is possible if you can check in a function if one of the arguments is temporary. What I mean is the following. A is a class, foo is a function returning a class...
1
by: subramanian100in | last post by:
Consider the following: int x; int y; int z; (x+y) = z; For this statement, I get the following error with g++ compiler: error: non-lvalue in assignment Suppose I have a class Test and x,...
3
by: subramanian100in | last post by:
Consider the code fragment: vector<intcontainer; container.insert(container.begin(), 10); int& ref = *--container.end(); From this, it looks like we can apply prefix decrement operator to...
2
by: anon.asdf | last post by:
Hello! 1) =============================== When trying to define an array of std::string ... func( (std::string ) { std::string("ab"), std::string("cd"), std::string("ef") } , 3 ); ...
6
by: better_cs_now | last post by:
Hello all, class Foo {/* Details don't matter */}; class Bar { public: Bar(): m_Foo(/* Construct a Foo however it wants to be constructed */); const Foo &GetFoo() const { return m_Foo; }...
4
by: James Kanze | last post by:
On Nov 18, 5:50 pm, Pete Becker <p...@versatilecoding.comwrote: Has this changed in the latest draft. According to my copy of the standard (version 1998---out of date, I know), "The...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.