📄 char_traits.html
字号:
<HTML><!-- -- Copyright (c) 1996-1999 -- Silicon Graphics Computer Systems, Inc. -- -- Permission to use, copy, modify, distribute and sell this software -- and its documentation for any purpose is hereby granted without fee, -- provided that the above copyright notice appears in all copies and -- that both that copyright notice and this permission notice appear -- in supporting documentation. Silicon Graphics makes no -- representations about the suitability of this software for any -- purpose. It is provided "as is" without express or implied warranty. -- -- Copyright (c) 1994 -- Hewlett-Packard Company -- -- Permission to use, copy, modify, distribute and sell this software -- and its documentation for any purpose is hereby granted without fee, -- provided that the above copyright notice appears in all copies and -- that both that copyright notice and this permission notice appear -- in supporting documentation. Hewlett-Packard Company makes no -- representations about the suitability of this software for any -- purpose. It is provided "as is" without express or implied warranty. -- --><Head><Title>char_traits</Title><!-- Generated by htmldoc --></HEAD><BODY BGCOLOR="#ffffff" LINK="#0000ee" TEXT="#000000" VLINK="#551a8b" ALINK="#ff0000"> <IMG SRC="CorpID.gif" ALT="SGI" HEIGHT="43" WIDTH="151"> <!--end header--><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 usedby 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 atemplate parameter of other classes, such as the <tt><A href="basic_string.html">basic_string</A></tt>template. <h3>Definition</h3>Defined in the standard header <A href="string">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 arbitrarytypes, but some of <tt>char_traits</tt>'s members must be explicitly specializedif <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 reasonto 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">string</A></tt><!--start footer--> <HR SIZE="6"><A href="http://www.sgi.com/"><IMG SRC="surf.gif" HEIGHT="54" WIDTH="54" ALT="[Silicon Surf]"></A><A HREF="index.html"><IMG SRC="stl_home.gif" HEIGHT="54" WIDTH="54" ALT="[STL Home]"></A><BR><FONT SIZE="-2"><A href="http://www.sgi.com/Misc/sgi_info.html" TARGET="_top">Copyright © 1999 Silicon Graphics, Inc.</A> All Rights Reserved.</FONT><FONT SIZE="-3"><a href="http://www.sgi.com/Misc/external.list.html" TARGET="_top">TrademarkInformation</A></FONT><P></BODY></HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -