[Patch] Fix the narrow/widen problem in money_get::do_get

Paolo Carlini pcarlini@suse.de
Thu Feb 26 19:53:00 GMT 2004


Martin Sebor wrote:

>> Honestly, I don't follow. It seems to me pretty clear that the standard
>> talks about widen, not about narrow (see note 237!?!)
>
> That's true. But existing practice suggests that the requirement
> is bogus -- no implementation that I know of has ever followed it.

Really?!? Therefore you are telling me that all those implementations
completely ignore 22.2.6.1.2, p4 and the note?!?

> You should care. Look at table 52. A conforming implementation
> is required to make it possible to instantiate money_get, money_put,
> num_get, and num_put on any POD character type.

I stand corrected about this, sorry.

>> Moreover, I don't see DRs involving 22.2.6.1.2.
>
> If there isn't one it's only because no one has filed it yet.
>
> The "missing traits" problem has been discussed a bunch of
> times. The only thing facets need traits for is character
> comparison. Unless we add a traits parameter to the facets
> that need it, the only two ways to solve the problem are
> to require that charT's be equality-comparable (no such
> requirement currently exists) or to have xxx_get<charT>::
> do_get() call ctype<charT>::narrow() and compare the narrowed
> down versions of the charT's. Actually, I suggested a third
> approach -- have the facets look for a traits_type typedef
> in the charT type and use it if it exists, and otherwise use
> std::char_traits<char>. This approach didn't meet with much
> enthusiasm, but neither was there a clear preference for
> either of the other two.

Wait a minute: if I understand well what you saying about the
"missing traits", the same issue would affect num_get and 22.2.2.1.2, p8
and our reading of it, because of course for num_get::do_get we
are following the very same approach, using traits::find and
widening in advance. Clearly strictly following the standard.

If that is the case, I (we) will definitely go ahead with my
money_get::do_get patch, if only for consistency with the
rest of our implementation.

If, on the other hand, the problem is restricted to money_get
I can consider discussing here the issue somewhat more.

Paolo.



More information about the Libstdc++ mailing list