einaros
Holger Grund wrote: |
einaros wrote: |
Right on the money. And for what it's worth, any newer gcc will do the same.
If you really do want to use such a horrid syntax (and I believe the "fix" shows how horrid it really is), you could pull a call to the global operator such as "cout << static_cast<ostringstream&>(operator << (ostringstream(), "TEST")).str();"
As for non-const rvalue references, I doubt that this behaviour will change much anytime soon, as it's likely to break a lot of existing code.
| |
I don't quite agree, I'm afraid. We've been hearing these arguments regarding nonconst reference binding for a decade now. There are a couple of cases where the generated code silently fails (or at least does something very odd - e.g.
http://forums.microsoft.com/MSDN/ShowPost.aspx PostID=1848959&SiteID=1 )
| |
Well I never said I agreed either, but that seems to be the current state of things, not only at MSFT. The EDG front-end happily accepts it as well. GCC and Comeau, on the other hand, complains as they should.
Holger Grund wrote: |
Your fix is really ill-formed C++
| |
Hence the double quotes around "fix" 
Holger Grund wrote: |
for the same reasons why overload resolution doesn't consider it and there are alternatives, which aren't really worse (e.g. use a fake manipulator such as std tringstream() << std:ec << "" << "TEST").
I don't really see the advantage of having everything in a single statement in this case. | |
And that's my point exactly, in case that was unclear in my previous post. Not only is that syntax unlikely to compile across vendors (and versions), but being as obscure as it is, my opinion is that you needlessly make yourself vulnerable to compiler bugs. The less consistent the front-end vendors seem to be about any one concept, the more likely are there to be bugs related to that concept.