This is the mail archive of the
libstdc++@sourceware.cygnus.com
mailing list for the libstdc++ project.
Re: a quick ofstream question
- To: Igor Markov <imarkov@cs.ucla.edu>, libstdc++@sourceware.cygnus.com
- Subject: Re: a quick ofstream question
- From: Dietmar Kuehl <dietmar.kuehl@claas-solutions.de>
- Date: Wed, 25 Aug 1999 03:51:22 +0200
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