ostream& operator<< (ostream&, bool)
Nathan Myers
ncm@cygnus.com
Mon Apr 13 15:57:00 GMT 1998
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
More information about the Gcc
mailing list