This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
Re: Q about ctype.narrow
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).
Martin