This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: ostream& operator<< (ostream&, bool)
- To: egcs at cygnus dot com
- Subject: Re: ostream& operator<< (ostream&, bool)
- From: Nathan Myers <ncm at cygnus dot com>
- Date: Mon, 13 Apr 1998 15:53:49 -0700
- Newsgroups: cygnus.egcs
- Organization: http://www.cantrip.org/
- References: <199804122345.BAA02784@piano.dptmaths.ens-cachan.fr>, <orogy6s4zg.fsf.cygnus.egcs@zecarneiro.lsd.dcc.unicamp.br>
Alexandre Oliva wrote:
>
> Gabriel Dos Reis writes:
>
> > shouldn't the output be looks like
>
> > true
> > false
>
> > instead of
>
> > 1
> > 0
>
> Not actually. This is controlled by the std::boolalpha ios
> manipulator, which is not implemented yet. The default behavior is to
> use the numeric format. In order to get the alphanumeric boolean
> representation, you'd have to use:
>
> cout << boolalpha << true << endl << false << endl;
Incidentally, the Draft is broken as regards
bool b;
cin >> boolalpha >> b;
It's quite embarrassing, but the code above has indeterminate results
because the Draft says if b (going in) is true, >> will try to match
"true", or if false, then "false", and report an error otherwise.
In other words, you have to know what you're about to read before you
read it. There will be a defect report about this.
Nathan Myers
ncm@cygnus.com