📄 char_traits.html
字号:
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<META NAME="Author" CONTENT="Zafir Anjum">
<TITLE>MFC Programmer's SourceBook : STL Programmer's Guide</TITLE>
<META name="description"
content="A freely available implementation
of the C++ Standard Template Library, including
hypertext documentation.">
<META name="keywords"
content="generic programming, STL, standard template library">
</HEAD>
<SCRIPT LANGUAGE="JavaScript"><!--
var adcategory = "cpp";
// -->
</SCRIPT>
<body background="../../fancyhome/back.gif" bgcolor="#FFFFFF" >
<SCRIPT LANGUAGE="JavaScript"><!--
var nfrm = location.href.indexOf("_nfrm_");
var validframes = (top.frames.length > 0 && top.frames['ad'] && top.frames['logo'] );
var random = Math.random();
if( !validframes && nfrm == -1 )
{
var dclkPage = "www.codeguru.com/";
if( self.adcategory )
dclkPage += adcategory;
else
dclkPage += "mfc";
document.write('<nolayer><center>');
document.write('<iframe src="http://ad.doubleclick.net/adi/' + dclkPage + ';ord='
+ random + '" width=470 height=62 marginwidth=0 marginheight=0 hspace=0 vspace=0 '
+ 'frameborder=0 scrolling=no bordercolor="#000000">');
document.write('<a href="http://ad.doubleclick.net/jump/' + dclkPage + ';ord='
+ random + '">');
document.write('<img src="http://ad.doubleclick.net/ad/' + dclkPage + ';ord='
+ random + '" height=60 width=468>' + '</a>');
document.write('</iframe>');
document.write('</center></nolayer>');
document.write('<layer src="http://ad.doubleclick.net/adl/' + dclkPage +
';ord=' + random + '"></layer>');
document.write('<ilayer visibility=hide width=468 height=83></ilayer>');
}
// top.location = "/show.cgi?" + adcategory + "=" + location.pathname;
// -->
</SCRIPT>
<noscript>
<p align="center">
<a href="http://ad.doubleclick.net/jump/www.codeguru.com/cpp;ord=NupaXNFCY34AAHeqWA8">
<img src="http://ad.doubleclick.net/ad/www.codeguru.com/cpp;ord=NupaXNFCY34AAHeqWA8"></a>
</p>
</noscript>
<BR Clear>
<H1>char_traits</H1>
<Table CellPadding=0 CellSpacing=0 width=100%>
<TR>
<TD Align=left><Img src = "utilities.gif" Alt="" WIDTH = "194" HEIGHT = "38" ></TD>
<TD Align=right><Img src = "type.gif" Alt="" WIDTH = "194" HEIGHT = "39" ></TD>
</TR>
<TR>
<TD Align=left VAlign=top><b>Category</b>: utilities</TD>
<TD Align=right VAlign=top><b>Component type</b>: type</TD>
</TR>
</Table>
<h3>Description</h3>
The <tt>char_traits</tt> class is the default <A href="character_traits.html">Character Traits</A> class used
by the library; it is the only predefined <A href="character_traits.html">Character Traits</A> class.
<h3>Example</h3>
The <tt>char_traits</tt> class is of no use by itself. It is used as a
template parameter of other classes, such as the <tt><A href="basic_string.html">basic_string</A></tt>
template.
<h3>Definition</h3>
Defined in <A href="string/index.htm">string</A>.
<h3>Template parameters</h3>
<Table border>
<TR>
<TH>
Parameter
</TH>
<TH>
Description
</TH>
<TH>
Default
</TH>
</TR>
<TR>
<TD VAlign=top>
<tt>charT</tt>
</TD>
<TD VAlign=top>
<tt>char_traits</tt>'s value type, <i>i.e.</i> <tt>char_traits<>::char_type</tt>.
</TD>
<TD VAlign=top>
</TD>
</tr>
</table>
<h3>Model of</h3>
<A href="character_traits.html">Character Traits</A>
<h3>Type requirements</h3>
<tt>charT</tt> is either <tt>char</tt> or <tt>wchar_t</tt>.
<P>
(All of <tt>char_traits</tt>'s member functions are defined for arbitrary
types, but some of <tt>char_traits</tt>'s members must be explicitly specialized
if <tt>char_traits</tt> is to be useful for other types than <tt>char</tt> and
<tt>wchar_t</tt>.
<h3>Public base classes</h3>
None.
<h3>Members</h3>
All of <tt>char_traits</tt>'s members are static. There is never any reason
to create an object of type <tt>char_traits</tt>.
<Table border>
<TR>
<TH>
Member
</TH>
<TH>
Where defined
</TH>
<TH>
Description
</TH>
</TR>
<TR>
<TD VAlign=top>
<tt>char_type</tt>
</TD>
<TD VAlign=top>
<A href="character_traits.html">Character Traits</A>
</TD>
<TD VAlign=top>
<tt>char_traits</tt>'s value type: <tt>charT</tt>.
</TD>
</TR>
<TR>
<TD VAlign=top>
<tt>int_type</tt>
</TD>
<TD VAlign=top>
<A href="character_traits.html">Character Traits</A>
</TD>
<TD VAlign=top>
<tt>char_traits</tt>'s int type.
</TD>
</TR>
<TR>
<TD VAlign=top>
<tt>pos_type</tt>
</TD>
<TD VAlign=top>
<A href="character_traits.html">Character Traits</A>
</TD>
<TD VAlign=top>
<tt>char_traits</tt>'s position type.
</TD>
</TR>
<TR>
<TD VAlign=top>
<tt>off_type</tt>
</TD>
<TD VAlign=top>
<A href="character_traits.html">Character Traits</A>
</TD>
<TD VAlign=top>
<tt>char_traits</tt>'s offset type
</TD>
</TR>
<TR>
<TD VAlign=top>
<tt>state_type</tt>
</TD>
<TD VAlign=top>
<A href="character_traits.html">Character Traits</A>
</TD>
<TD VAlign=top>
<tt>char_traits</tt>'s state type.
</TD>
</TR>
<TR>
<TD VAlign=top>
<tt>static void assign(char_type& c1, const char_type& c2)</tt>
</TD>
<TD VAlign=top>
<A href="character_traits.html">Character Traits</A>
</TD>
<TD VAlign=top>
Assigns <tt>c2</tt> to <tt>c1</tt>.
</TD>
</TR>
<TR>
<TD VAlign=top>
<tt>static bool eq(const char_type& c1, const char_type& c2)</tt>
</TD>
<TD VAlign=top>
<A href="character_traits.html">Character Traits</A>
</TD>
<TD VAlign=top>
Character equality.
</TD>
</TR>
<TR>
<TD VAlign=top>
<tt>static bool lt(const char_type& c1, const char_type& c2)</tt>
</TD>
<TD VAlign=top>
<A href="character_traits.html">Character Traits</A>
</TD>
<TD VAlign=top>
Returns <tt>true</tt> if <tt>c1</tt> is less than <tt>c2</tt>.
</TD>
</TR>
<TR>
<TD VAlign=top>
<tt>static int compare(const char_type* p1, const char_type* p2, size_t n)</tt>
</TD>
<TD VAlign=top>
<A href="character_traits.html">Character Traits</A>
</TD>
<TD VAlign=top>
Three-way lexicographical comparison, much like <tt>strncmp</tt>.
</TD>
</TR>
<TR>
<TD VAlign=top>
Length
</TD>
<TD VAlign=top>
<tt>static size_t length(const char* p)</tt>
</TD>
<TD VAlign=top>
Returns length of a null-terminated array of characters.
</TD>
</TR>
<TR>
<TD VAlign=top>
<tt>static const char_type* find(const char_type* p, size_t n, const char_type& c)</tt>
</TD>
<TD VAlign=top>
<A href="character_traits.html">Character Traits</A>
</TD>
<TD VAlign=top>
Finds <tt>c</tt> in <tt>[p, p+n)</tt>, returning 0 if not found.
</TD>
</TR>
<TR>
<TD VAlign=top>
<tt>static char_type* move(char_type* s, const char_type* p, size_t n)</tt>
</TD>
<TD VAlign=top>
<A href="character_traits.html">Character Traits</A>
</TD>
<TD VAlign=top>
Copies characters from <tt>[p, p+n)</tt> to the (possibly overlapping)
range <tt>[s, s+n)</tt>.
</TD>
</TR>
<TR>
<TD VAlign=top>
<tt>static char_type* copy(char_type* s, const char_type* p, size_t n)</tt>
</TD>
<TD VAlign=top>
<A href="character_traits.html">Character Traits</A>
</TD>
<TD VAlign=top>
Copies characters from <tt>[p, p+n)</tt> to the (non-overlapping)
range <tt>[s, s+n)</tt>.
</TD>
</TR>
<TR>
<TD VAlign=top>
<tt>static char_type* assign(char_type* s, size_t n, char_type c)</tt>
</TD>
<TD VAlign=top>
<A href="character_traits.html">Character Traits</A>
</TD>
<TD VAlign=top>
Assigns the value <tt>c</tt> to every element in the range <tt>[s, s+n)</tt>.
</TD>
</TR>
<TR>
<TD VAlign=top>
<tt>static int_type eof()</tt>
</TD>
<TD VAlign=top>
<A href="character_traits.html">Character Traits</A>
</TD>
<TD VAlign=top>
Returns the value used as an EOF indicator.
</TD>
</TR>
<TR>
<TD VAlign=top>
<tt>static int_type not_eof(const int_type& c)</tt>
</TD>
<TD VAlign=top>
<A href="character_traits.html">Character Traits</A>
</TD>
<TD VAlign=top>
Returns a value that is not equal to <tt>eof()</tt>. Returns <tt>c</tt> unless
<tt>c</tt> is equal to <tt>eof()</tt>.
</TD>
</TR>
<TR>
<TD VAlign=top>
<tt>static char_type to_char_type(const int_type& c)</tt>
</TD>
<TD VAlign=top>
<A href="character_traits.html">Character Traits</A>
</TD>
<TD VAlign=top>
Returns the <tt>char_type</tt> value corresponding to <tt>c</tt>, if such a value
exists.
</TD>
</TR>
<TR>
<TD VAlign=top>
<tt>static int_type to_int_type(const char_type& c)</tt>
</TD>
<TD VAlign=top>
<A href="character_traits.html">Character Traits</A>
</TD>
<TD VAlign=top>
Returns a <tt>int_type</tt> representation of <tt>c</tt>.
</TD>
</TR>
<TR>
<TD VAlign=top>
<tt>static bool eq_int_type(cosnt int_type& c1, const int_type& c1)</tt>
</TD>
<TD VAlign=top>
<A href="character_traits.html">Character Traits</A>
</TD>
<TD VAlign=top>
Tests whether two <tt>int_type</tt> values are equal. If the values can
also be represented as <tt>char_type</tt>, then <tt>eq</tt> and <tt>eq_int_type</tt> must
be consistent with each other.
</TD>
</tr>
</table>
<h3>New members</h3>
None. All of <tt>char_traits</tt>'s members are defined in the
<A href="character_traits.html">Character Traits</A> requirements.
<h3>Notes</h3>
<h3>See also</h3>
<A href="character_traits.html">Character Traits</A>, <tt><A href="basic_string.html" tppabs="http://www.sgi.com/Technology/STL/basic_string.shtml">string</A></tt>
<HR SIZE="6"> <FONT SIZE="-2"> Copyright © 1996 Silicon Graphics, Inc.
<HR>
<TABLE BORDER=0 WIDTH="100%" >
<TR>
<TD WIDTH="33%"><FONT SIZE=-1><A HREF="index.html" >
STL</A></FONT></TD>
<TD WIDTH="33%">
<CENTER><FONT SIZE=-2>© Copyright 1997-1998 CodeGuru</FONT> </CENTER>
</TD>
<TD WIDTH="34%">
<DIV ALIGN=right><FONT SIZE=-1>Contact : <A HREF="mailto:webmaster@codeguru.com">webmaster@codeguru.com</A> </FONT></DIV>
</TD>
</TR>
</TABLE>
<SCRIPT LANGUAGE="JavaScript" ><!--
var adurl = "/cgi-bin/doubleclick.cgi?";
if( self.adcategory )
adurl += adcategory;
else
adurl += "mfc";
if( self.parent.norefreshad )
parent.norefreshad = false;
else if( validframes )
parent.frames['ad'].location = adurl;
if( !validframes && nfrm == -1)
{
var dclkPage = "www.codeguru.com/";
if( self.adcategory )
dclkPage += adcategory;
else
dclkPage += "mfc";
// var random = Math.random();
document.write('<nolayer><center>');
document.write('<iframe src="http://ad.doubleclick.net/adi/' + dclkPage + ';ord='
+ random + '" width=470 height=62 marginwidth=0 marginheight=0 hspace=0 vspace=0 '
+ 'frameborder=0 scrolling=no bordercolor="#000000">');
document.write('<a href="http://ad.doubleclick.net/jump/' + dclkPage + ';ord='
+ random + '">');
document.write('<img src="http://ad.doubleclick.net/ad/' + dclkPage + ';ord='
+ random + '" height=60 width=468>' + '</a>');
document.write('</iframe>');
document.write('</center></nolayer>');
document.write('<layer src="http://ad.doubleclick.net/adl/' + dclkPage +
';ord=' + random + '"></layer>');
document.write('<ilayer visibility=hide width=468 height=83></ilayer>');
}
// -->
</SCRIPT>
<!-- SCRIPT LANGUAGE="JavaScript" SRC="/global/fscript.js">
//
</SCRIPT -->
<noscript>
<p align="center">
<a href="http://ad.doubleclick.net/jump/www.codeguru.com/cpp;ord=NupaXNFCY34AAHeqWA8">
<img src="http://ad.doubleclick.net/ad/www.codeguru.com/cpp;ord=NupaXNFCY34AAHeqWA8"></a>
</p>
</noscript>
</BODY>
</HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -