This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
RE: Q about ctype.narrow
- From: Pétur Runólfsson <peturr02 at ru dot is>
- To: "Martin Sebor" <sebor at roguewave dot com>,"libstdc++" <libstdc++ at gcc dot gnu dot org>
- Date: Thu, 27 Nov 2003 19:13:44 -0000
- Subject: RE: Q about ctype.narrow
Martin Sebor wrote:
> Pétur Runólfsson wrote:
>
> ...
> > The numpunct_cache meets this requirement, so it's OK. Also, since
> > only facets that are installed in locales are bound by this rule,
> > this would be OK, so long as this facet is never put in a locale:
> >
> > class Qux : public ctype<char>
> > {
> > protected:
> > char do_widen(char c) const { return (c + time(NULL)) % 256; }
> > };
>
> This usage was also, I'm sure, not intended -- the (admittedly
> non-normative) note in 22.1.1, p5 makes it pretty clear, IMO:
>
> -5- [Note: All locale semantics are accessed via use_facet<>
> and has_facet<>, except that: ...
>
> I.e., you have to install a facet in a locale before calling any
> of its member functions, and you can only call them after a call
> to use_facet on that locale. Our implementation even relies on
> it (i.e., some facets, including ctype, will not work correctly
> otherwise).
That's not how I read that note. I read it as "The only way to get
information out of locale objects is through use_facet<> and
has_facet<>, except that...". In other words, I read it only as a
statement about class locale, not about localization in general.
This reading seems to make the most sense, since a) it is backed
by normative text, and b) this note appears in the description of
class locale.
Petur