⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 character_traits.html

📁 指导程序员合理、高效的进行标准模板库编程。
💻 HTML
📖 第 1 页 / 共 2 页
字号:
</TD>
</TR>
<TR>
<TD VAlign=top>
Equal int type values
</TD>
<TD VAlign=top>
<tt>X::eq_int_type(e1, e2)</tt>
</TD>
<TD VAlign=top>
&nbsp;
</TD>
<TD VAlign=top>
<tt>bool</tt>
</TD>
</tr>
</table>
<h3>Expression semantics</h3>
<Table border>
<TR>
<TH>
Name
</TH>
<TH>
Expression
</TH>
<TH>
Precondition
</TH>
<TH>
Semantics
</TH>
<TH>
Postcondition
</TH>
</TR>
<TR>
<TD VAlign=top>
Character assignment
</TD>
<TD VAlign=top>
<tt>X::assign(c1, c2)</tt>
</TD>
<TD VAlign=top>
&nbsp;
</TD>
<TD VAlign=top>
Performs the assignment <tt>c1 = c2</tt>
</TD>
<TD VAlign=top>
<tt>X::eq(c1, c2)</tt> is <tt>true</tt>.
</TD>
</TR>
<TR>
<TD VAlign=top>
Character equality
</TD>
<TD VAlign=top>
<tt>X::eq(c1, c2)</tt>
</TD>
<TD VAlign=top>
&nbsp;
</TD>
<TD VAlign=top>
Returns <tt>true</tt> if and only if <tt>c1</tt> and <tt>c2</tt> are equal.
</TD>
<TD VAlign=top>
&nbsp;
</TD>
</TR>
<TR>
<TD VAlign=top>
Character comparison
</TD>
<TD VAlign=top>
<tt>X::lt(c1, c2)</tt>
</TD>
<TD VAlign=top>
&nbsp;
</TD>
<TD VAlign=top>
Returns <tt>true</tt> if and only if <tt>c1</tt> is less than <tt>c2</tt>.  Note that
   for any two value values <tt>c1</tt> and <tt>c2</tt>, exactly one of 
   <tt>X::lt(c1, c2)</tt>, <tt>X::lt(c2, c1)</tt>, and <tt>X::eq(c1, c2)</tt> should be
   <tt>true</tt>.
</TD>
<TD VAlign=top>
&nbsp;
</TD>
</TR>
<TR>
<TD VAlign=top>
Range comparison
</TD>
<TD VAlign=top>
<tt>X::compare(p1, p2, n)</tt>
</TD>
<TD VAlign=top>
<tt>[p1, p1+n)</tt> and <tt>[p2, p2+n)</tt> are valid ranges.
</TD>
<TD VAlign=top>
Generalization of <tt>strncmp</tt>.  Returns <tt>0</tt> if every element
   in <tt>[p1, p1+n)</tt> is equal to the corresponding element 
   in <tt>[p2, p2+n)</tt>, a negative value if there exists an element
   in <tt>[p1, p1+n)</tt> less than the corresponding element in <tt>[p2, p2+n)</tt>
   and all previous elements are equal, and a positive value 
   if there exists an element in <tt>[p1, p1+n)</tt> greater than the
   corresponding element in <tt>[p2, p2+n)</tt> and all previous elements
   are equal.
</TD>
<TD VAlign=top>
&nbsp;
</TD>
</TR>
<TR>
<TD VAlign=top>
Length
</TD>
<TD VAlign=top>
<tt>X::length(p)</tt>
</TD>
<TD VAlign=top>
&nbsp;
</TD>
<TD VAlign=top>
Generalization of <tt>strlen</tt>.
   Returns the smallest non-negative number <tt>n</tt> such that 
   <tt>X::eq(p+n, X::char_type())</tt> is true.  Behavior is undefined
   if no such <tt>n</tt> exists.
</TD>
<TD VAlign=top>
&nbsp;
</TD>
</TR>
<TR>
<TD VAlign=top>
Find
</TD>
<TD VAlign=top>
<tt>X::find(p, n, c)</tt>
</TD>
<TD VAlign=top>
<tt>[p, p+n)</tt> is a valid range.
</TD>
<TD VAlign=top>
Generalization of <tt>strchr</tt>.  Returns the first pointer <tt>q</tt>
   in <tt>[p, p+n)</tt> such that <tt>X::eq(*q, c)</tt> is true.  Returns a 
   null pointer if no such pointer exists.  (Note that this method
   for indicating a failed search differs from that is 
   <tt><A href="find.html">find</A></tt>.)
</TD>
<TD VAlign=top>
&nbsp;
</TD>
</TR>
<TR>
<TD VAlign=top>
Move
</TD>
<TD VAlign=top>
<tt>X::move(s, p, n)</tt>
</TD>
<TD VAlign=top>
<tt>[p, p+n)</tt> and <tt>[s, s+n)</tt> are valid ranges (possibly overlapping).
</TD>
<TD VAlign=top>
Generalization of <tt>memmove</tt>.  Copies values from the range
   <tt>[p, p+n)</tt> to the range <tt>[s, s+n)</tt>, and returns <tt>s</tt>.
</TD>
<TD VAlign=top>
&nbsp;
</TD>
</TR>
<TR>
<TD VAlign=top>
Copy
</TD>
<TD VAlign=top>
<tt>X::copy(s, p, n)</tt>
</TD>
<TD VAlign=top>
<tt>[p, p+n)</tt> and <tt>[s, s+n)</tt> are valid ranges which do not overlap.
</TD>
<TD VAlign=top>
Generalization of <tt>memcpy</tt>.  Copies values from the range
   <tt>[p, p+n)</tt> to the range <tt>[s, s+n)</tt>, and returns <tt>s</tt>.
</TD>
<TD VAlign=top>
&nbsp;
</TD>
</TR>
<TR>
<TD VAlign=top>
Range assignment
</TD>
<TD VAlign=top>
<tt>X::assign(s, n, c)</tt>
</TD>
<TD VAlign=top>
<tt>[s, s+n)</tt> is a valid range.
</TD>
<TD VAlign=top>
Generalization of <tt>memset</tt>.  Assigns the value <tt>c</tt> to each pointer
   in the range <tt>[s, s+n)</tt>, and returns <tt>s</tt>.
</TD>
<TD VAlign=top>
&nbsp;
</TD>
</TR>
<TR>
<TD VAlign=top>
EOF value
</TD>
<TD VAlign=top>
<tt>X::eof()</tt>
</TD>
<TD VAlign=top>
&nbsp;
</TD>
<TD VAlign=top>
Returns a value that can represent EOF.
</TD>
<TD VAlign=top>
<tt>X::eof()</tt> is distinct from every valid value of type
   <tt>X::char_type</tt>.  That is, there exists no value <tt>c</tt>
   such that <tt>X::eq_int_type(X::to_int_type(c), X::eof())</tt> is <tt>true</tt>.
</TD>
</TR>
<TR>
<TD VAlign=top>
Not EOF
</TD>
<TD VAlign=top>
<tt>X::not_eof(e)</tt>
</TD>
<TD VAlign=top>
&nbsp;
</TD>
<TD VAlign=top>
Returns <tt>e</tt> if <tt>e</tt> represents a valid <tt>char_type</tt> value, and some
   non-EOF value if <tt>e</tt> is <tt>X::eof()</tt>.
</TD>
<TD VAlign=top>
&nbsp;
</TD>
</TR>
<TR>
<TD VAlign=top>
Convert to value type
</TD>
<TD VAlign=top>
<tt>X::to_char_type(e)</tt>
</TD>
<TD VAlign=top>
&nbsp;
</TD>
<TD VAlign=top>
Converts <tt>e</tt> to <tt>X</tt>'s int type.  If <tt>e</tt> is a representation of some
   <tt>char_type</tt> value then it returns that value; if <tt>e</tt> is <tt>X::eof()</tt>
   then the return value is unspecified.
</TD>
<TD VAlign=top>
&nbsp;
</TD>
</TR>
<TR>
<TD VAlign=top>
Convert to int type
</TD>
<TD VAlign=top>
<tt>X::to_int_type(c)</tt>
</TD>
<TD VAlign=top>
&nbsp;
</TD>
<TD VAlign=top>
Converts <tt>c</tt> to <tt>X</tt>'s int type.
</TD>
<TD VAlign=top>
<tt>X::to_char_type(X::to_int_type(c))</tt> is a null operation.
</TD>
</TR>
<TR>
<TD VAlign=top>
Equal int type values
</TD>
<TD VAlign=top>
<tt>X::eq_int_type(e1, e2)</tt>
</TD>
<TD VAlign=top>
&nbsp;
</TD>
<TD VAlign=top>
Compares two int type values.  If there exist values of type
   <tt>X::char_type</tt> such that <tt>e1</tt> is <tt>X::to_int_type(c1))</tt> and
   <tt>e2</tt> is <tt>X::to_int_type(c2))</tt>, then <tt>X::eq_int_type(e1, e2)</tt> is
   the same as <tt>X::eq(c1, c2)</tt>.  Otherwise, <tt>eq_int_type</tt> returns
   <tt>true</tt> if <tt>e1</tt> and <tt>e2</tt> are both EOF and <tt>false</tt> if one of
   <tt>e1</tt> and <tt>e2</tt> is EOF and the other is not.
</TD>
<TD VAlign=top>
&nbsp;
</TD>
</tr>
</table>
<h3>Complexity guarantees</h3>
<tt>length</tt>, <tt>find</tt>, <tt>move</tt>, <tt>copy</tt>, and the range version of <tt>assign</tt>
are linear in <tt>n</tt>.
<P>
All other operations are constant time.
<h3>Models</h3>
<UL>
<LI>
<tt><A href="char_traits.html">char_traits</A>&lt;char&gt;</tt>
<LI>
<tt><A href="char_traits.html">char_traits</A>&lt;wchar_t&gt;</tt>
</UL>
<h3>Notes</h3>
<h3>See also</h3>
<tt><A href="basic_string.html">string</A></tt>

<HR SIZE="6"> <FONT SIZE="-2"> Copyright &copy; 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>&copy; Copyright 1997-1998 CodeGuru</FONT>&nbsp;</CENTER>
</TD>

<TD WIDTH="34%">
<DIV ALIGN=right><FONT SIZE=-1>Contact : <A HREF="mailto:webmaster@codeguru.com">webmaster@codeguru.com</A>&nbsp;</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=NupaWdFCY34AAHbDKXQ">
<img src="http://ad.doubleclick.net/ad/www.codeguru.com/cpp;ord=NupaWdFCY34AAHbDKXQ"></a>
</p>
</noscript>





</BODY>
</HTML>


⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -