This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


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

Re: ostream& operator<< (ostream&, bool)


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


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