Topic: num_get for bool


Author: david@kai.com (David C. Nelson)
Date: 1998/05/29
Raw View
After getting bit by a less than perfect implementation of
num_get<>::do_get for bool, I took a look at that section of the draft
standard.  (22.2.2.1.2 [lib.facet.num.get.virtuals]) I hope this has
received some attention since CD2 was released. In the last few
paragraphs of that section it describes the effects of do_get for
bool. It starts out with the gem: "str.flags()&&ios_base::boolalpha"
where everything after "str" is in bold. It also uses a logical AND
rather than a bitwise AND. The rest of the paragraph is fairly clear.

The next paragraph needs some attention:

> Otherwise a target string to be matched is determined by calling
> either use_facet<ctype<charT> >(loc).truename() or
> use_facet<ctype<charT> >(loc).falsename() depending on whether val is
> true or false (respectively).

First, the facet ctype<> does not have a method called truename().
That method is in numpunct<>. Second, since val is not set yet, how
is one supposed to use it to select which string to compare the input
sequence? It seems reasonable that both methods are called and the
input sequence is compared to both. When a complete match is made, val
is set to the corresponding value.

I just noticed that the ctype<> facet is also used in the
corresponding num_put section. It should be replaced with numpunct
also.

--
#include <std/disclaimer.h>                 Kuck and Associates
David Nelson (david@kai.com)                1906 Fox Drive
http://www.kai.com/C_plus_plus/_index.html  Champaign, IL   61820
KAI C++ - Cross Platform C++ Compiler       (217) 356-2288 ext 36


[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html              ]






Author: ncm@nospam.cantrip.org (Nathan Myers)
Date: 1998/05/30
Raw View
David C. Nelson<david@kai.com> wrote (very astutely):
>After getting bit by a less than perfect implementation of
>num_get<>::do_get for bool, I took a look at that section of the draft
>standard.  (22.2.2.1.2 [lib.facet.num.get.virtuals]) I hope this has
>received some attention since CD2 was released.

Unfortunately these errors are still present in the Draft.
This will certainly be the subject of a Defect Report.  In
the meantime, reading in boolean values by name will not be
among the best ways to use the standard library.

--
Nathan Myers
ncm@nospam.cantrip.org  http://www.cantrip.org/



[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html              ]