This is the mail archive of the libstdc++@sourceware.cygnus.com mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: a quick ofstream question


Hi,
At 18:19 24.08.99 -0700, Igor Markov wrote:
>    while porting code from CC4.2 to g++2.95(.1), I noticed that
>      ofstream("filename") << myVar;

This should not work: You cannot bind a temporary to a non-const reference.
However, the first argument to the output operator is normally a non-const
reference to 'ostream&' (or 'basic_ostream<cT, traits>'). g++ is correct,
CC4.2 is not. I guess CC5.* is also correct, ie. will reject this code.

>    It is conceivable that g++ does not want to apply a non-const
>    op<< to a temporary, but I was wondering if this is according 
>    to the C++ standard (if not, does V3 allow this).

Yes, it is according to the standard.

Dietmar

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]