This is the mail archive of the
mailing list for the libstdc++ project.
Re: Char_traits (part 2+)
- From: Matt Austern <austern at apple dot com>
- To: Gabriel Dos Reis <gdr at integrable-solutions dot net>
- Cc: Benjamin Kosnik <bkoz at redhat dot com>, jack_reeves at hotmail dot com, libstdc++ at gcc dot gnu dot org
- Date: Fri, 16 Aug 2002 12:20:13 -0700
- Subject: Re: Char_traits (part 2+)
On Friday, August 16, 2002, at 11:42 AM, Gabriel Dos Reis wrote:
Sometime ago (one? two years), I was working on the char_traits<>
thingy seeking for ways to provide points-of-customization for users
-- but I gave up, being distracted by other things (and ironically
enough, I ditched the patch from my disk two weeks ago :-(( )
The real problem is that specializing char_traits isn't enough.
A user who wants to define a new character type, and have it
be usable on equal footing with char and wchar_t, must do
- Define a new POD type foo
- Specialize char_traits<foo>
- Specialize ctype<foo>
- Specialize numpunct<foo>
- Specialize moneypunct<foo>
- Specialize time_get<foo> and time_put<foo>
- Specialize messages<foo>
- Install your specialized facets into every locale you want to
use in conjunction with your new type.
The first three are reasonable enough: you define a type, and
you tell the system its traits. The others are a mess. You'll
have to rewrite lots of the guts of a standard library
implementation. The granularity of this customization is
awkward at best.
(And note that this still won't get you the ability to use your
new character type with named locales. All it'll get you is
the ability to imbue a stream with *some* locale that works.
If you want to use your new character type, and also use
locales to encapsulate different cultural conventions, you've
got more work ahead of you. I'm not sure how much more work,
because I'm not sure what the interface might look like.)
A project I've been putting off for several years is defining
a new character type, doing all the user-level library work that's
required to get it to work (i.e. not taking advantage of any
library implementation's private internals), and writing an article
showing other people how to do it. It's a nontrivial project.
If anyone wants to work with me on it, it might finally get me to