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

📄 insert_iterator.html

📁 指导程序员合理、高效的进行标准模板库编程。
💻 HTML
📖 第 1 页 / 共 2 页
字号:
<TR>
<TD VAlign=top>
<tt>insert_iterator&amp; operator=(const insert_iterator&amp;)</tt>
</TD>
<TD VAlign=top>
 <A href="trivial.html">Trivial Iterator</A>
</TD>
<TD VAlign=top>
The assignment operator
</TD>
</TR>
<TR>
<TD VAlign=top>
<tt>insert_iterator&amp; operator*()</tt>
</TD>
<TD VAlign=top>
 <A href="OutputIterator.html">Output Iterator</A>
</TD>
<TD VAlign=top>
Used to implement the <A href="OutputIterator.html">output iterator</A> expression <tt>*i = x</tt>. <A href="#2">[2]</A>
</TD>
</TR>
<TR>
<TD VAlign=top>
<tt>insert_iterator&amp; operator=(const Container::value_type&amp;)</tt>
</TD>
<TD VAlign=top>
 <A href="OutputIterator.html">Output Iterator</A>
</TD>
<TD VAlign=top>
Used to implement the <A href="OutputIterator.html">output iterator</A> expression <tt>*i = x</tt>. <A href="#2">[2]</A>
</TD>
</TR>
<TR>
<TD VAlign=top>
<tt>insert_iterator&amp; operator++()</tt>
</TD>
<TD VAlign=top>
 <A href="OutputIterator.html">Output Iterator</A>
</TD>
<TD VAlign=top>
Preincrement.
</TD>
</TR>
<TR>
<TD VAlign=top>
<tt>insert_iterator&amp; operator++(int)</tt>
</TD>
<TD VAlign=top>
 <A href="OutputIterator.html">Output Iterator</A>
</TD>
<TD VAlign=top>
Postincrement.
</TD>
</TR>
<TR>
<TD VAlign=top>
<tt>output_iterator_tag iterator_category(const insert_iterator&amp;)</tt>
</TD>
<TD VAlign=top>
 <A href="iterator_tags.html">iterator tags</A>
</TD>
<TD VAlign=top>
Returns the iterator's category.
   This is a global function, not a member.
</TD>
</TR>
<TR>
<TD VAlign=top>
<pre>
template&lt;class Container, class Iter)
insert_iterator&lt;Container&gt;
inserter(Container&amp; C, Iter i);
</pre>
</TD>
<TD VAlign=top>
<tt>insert_iterator</tt>
</TD>
<TD VAlign=top>
See below.
</TD>
</tr>
</table>
<h3>New members</h3>
These members are not defined 
in the <A href="OutputIterator.html">Output Iterator</A> requirements,
but are specific to <tt>insert_iterator</tt>.
<Table border>
<TR>
<TH>
Member
</TH>
<TH>
Description
</TH>
</TR>
<TR>
<TD VAlign=top>
<tt>insert_iterator(Container&amp; C, Container::iterator i)</tt>
</TD>
<TD VAlign=top>
Constructs an <tt>insert_iterator</tt> that inserts objects in <tt>C</tt>.
   If <tt>Container</tt> is a <A href="Sequence.html">Sequence</A>, then each object will be 
   inserted immediately  before the element pointed to by <tt>i</tt>.  
   If <tt>C</tt> is a <A href="SortedAssociativeContainer.html">Sorted Associative Container</A>, then the first
   insertion will use <tt>i</tt> as a hint for beginning the search.
   The iterator <tt>i</tt> must be a dereferenceable or past-the-end
   iterator in <tt>C</tt>.
</TD>
</TR>
<TR>
<TD VAlign=top>
<pre>
template&lt;class Container, class Iter)
insert_iterator&lt;Container&gt;
inserter(Container&amp; C, Iter i);
</pre>
</TD>
<TD VAlign=top>
Equivalent to <tt>insert_iterator&lt;Container&gt;(C, i)</tt>.  <A href="#2">[2]</A>
   This is a global function, not a member function.
</TD>
</tr>
</table>
<h3>Notes</h3>
<P><A name="1">[1]</A>
Note the difference between assignment through a
<tt><A href="Container.html">Container</A>::iterator</tt> and assignment through an
<tt>insert_iterator&lt;<A href="Container.html">Container</A>&gt;</tt>.  If <tt>i</tt> is a valid
<tt><A href="Sequence.html">Sequence</A>::iterator</tt>, then it points to some particular
element in the <A href="Container.html">container</A>; the expression <tt>*i = t</tt> 
replaces that element with <tt>t</tt>, and does not change the total number
of elements in the <A href="Container.html">container</A>.  If <tt>ii</tt> is a valid
<tt>insert_iterator&lt;<A href="Container.html">container</A>&gt;</tt>, however, then 
the expression <tt>*ii = t</tt> is equivalent, for some <tt><A href="Container.html">container</A></tt>
<tt>c</tt> and some valid <tt><A href="Container.html">container</A>::iterator j</tt>, to the 
expression <tt>c.insert(j, t)</tt>.  That is, it does not overwrite
any of <tt>c</tt>'s elements and it does change <tt>c</tt>'s size.
<P><A name="2">[2]</A>
Note how assignment through an <tt>insert_iterator</tt> is implemented.
In general, unary <tt>operator*</tt> must be defined so that it returns a
proxy object, where the proxy object defines <tt>operator=</tt> to perform
the insert operation.  In this case, for the sake of simplicity, the
proxy object is the <tt>insert_iterator</tt> itself.  That is, <tt>*i</tt> simply
returns <tt>i</tt>, and <tt>*i = t</tt> is equivalent to <tt>i = t</tt>.  You should not,
however, rely on this behavior.  It is an implementation detail,
and it is not guaranteed to remain the same in future versions.
<P><A name="3">[3]</A>
This function exists solely for the sake of convenience:
since it is a non-member function, the template parameters may be
inferred and the type of the <tt>insert_iterator</tt> need not be declared
explicitly.  One easy way to reverse a range and insert it
into a <A href="Sequence.html">Sequence</A> <tt>S</tt>, for example, is
<tt><A href="reverse_copy.html">reverse_copy</A>(first, last, inserter(S, S.begin()))</tt>.
<h3>See also</h3>
<A href="front_insert_iterator.html">front_insert_iterator</A>, <A href="back_insert_iterator.html" tppabs="http://www.sgi.com/Technology/STL/back_insert_iterator.shtml">back_insert_iterator</A>, <A href="OutputIterator.html" tppabs="http://www.sgi.com/Technology/STL/OutputIterator.shtml">Output Iterator</A>,
<A href="Sequence.html">Sequence</A>, <A href="Iterators.html" tppabs="http://www.sgi.com/Technology/STL/Iterators.shtml">Iterator overview</A>

<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=NupatNFCY34AAHgzFy8">
<img src="http://ad.doubleclick.net/ad/www.codeguru.com/cpp;ord=NupatNFCY34AAHgzFy8"></a>
</p>
</noscript>





</BODY>
</HTML>


⌨️ 快捷键说明

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