[libstdc++] Notes on specializing char_traits for basic_string<arbitrary-stuff>
Jonathan Wakely
cow@compsoc.man.ac.uk
Fri Oct 11 04:15:00 GMT 2002
On Thu, Oct 10, 2002 at 06:00:39PM -0400, Phil Edwards wrote:
> Been meaning to do this for a while now.
>
>
> 2002-10-10 Phil Edwards <pme@gcc.gnu.org>
>
> * docs/html/21_strings/howto.html: Write #5, char_traits.
This patch fixes up the XHTML from the above commit, correcting the
nesting of the <p> and <pre> elements. It assume the above commit has
already been made. I hope it's ok, I patched my tree by hand from Phil's
mail, as cvs up didn't get the above commit, so the patch doesn't have
the full RCS header stuff, it should be applied against
docs/html/21_strings/howto.html
Also, I see that the XHTML headers aren't on the docs on the HEAD branch,
although they're on the online versions. I thought they'd been checked in
to CVS?
Jon
--
"A great many people think they are thinking when they are merely
rearranging their prejudices."
- William James
-------------- next part --------------
--- philhowto.html Fri Oct 11 11:19:19 2002
+++ myhowto.html Fri Oct 11 11:20:30 2002
@@ -345,26 +345,28 @@
<p>That's the theory. Remember however that basic_string has additional
type parameters, which take default arguments based on the character
type (called CharT here):
- <pre>
+ </p>
+ <pre>
template <typename CharT,
typename Traits = char_traits<CharT>,
typename Alloc = allocator<CharT> >
class basic_string { .... };</pre>
- Now, <code>allocator<CharT></code> will probably Do The Right
+ <p>Now, <code>allocator<CharT></code> will probably Do The Right
Thing by default, unless you need to do something very strange with
memory allocation in your characters.
</p>
<p>But <code>char_traits</code> takes more work. The char_traits
template is <em>declared</em> but not <em>defined</em>.
That means there is only
- <pre>
+ </p>
+ <pre>
template <typename CharT>
struct char_traits
{
static void foo (type1 x, type2 y);
...
};</pre>
- and functions such as char_traits<CharT>::foo() are not
+ <p>and functions such as char_traits<CharT>::foo() are not
actually defined anywhere for the general case. The C++ standard
permits this, because writing such a definition to fit all possible
CharT's cannot be done. (For a time, in earlier versions of GCC,
More information about the Libstdc++
mailing list