1<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> 2<html> 3<head> 4<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> 5<title>Concept OutputIterator</title> 6<link rel="stylesheet" href="../../doc/src/boostbook.css" type="text/css"> 7<meta name="generator" content="DocBook XSL Stylesheets V1.79.1"> 8<link rel="home" href="index.html" title="The Boost C++ Libraries BoostBook Documentation Subset"> 9<link rel="up" href="concept_check.html#concepts.reference" title="Concept reference"> 10<link rel="prev" href="InputIterator.html" title="Concept InputIterator"> 11<link rel="next" href="ForwardIterator.html" title="Concept ForwardIterator"> 12</head> 13<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"> 14<table cellpadding="2" width="100%"><tr> 15<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../boost.png"></td> 16<td align="center"><a href="../../index.html">Home</a></td> 17<td align="center"><a href="../../libs/libraries.htm">Libraries</a></td> 18<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td> 19<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td> 20<td align="center"><a href="../../more/index.htm">More</a></td> 21</tr></table> 22<hr> 23<div class="spirit-nav"> 24<a accesskey="p" href="InputIterator.html"><img src="../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="concept_check.html#concepts.reference"><img src="../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="index.html"><img src="../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="ForwardIterator.html"><img src="../../doc/src/images/next.png" alt="Next"></a> 25</div> 26<div class="refentry"> 27<a name="OutputIterator"></a><div class="titlepage"></div> 28<div class="refnamediv"> 29<h2><span class="refentrytitle">Concept OutputIterator</span></h2> 30<p>OutputIterator</p> 31</div> 32<div class="refsect1"> 33<a name="id-1.3.49.3.6.3"></a><h2>Description</h2> 34<p>An output iterator is an iterator that can write a sequence of 35 values. It is single-pass (old values of the iterator cannot be 36 re-used), and write-only.</p> 37<p>An output iterator represents a position in a (possibly infinite) 38 sequence. Therefore, the iterator can point into the sequence (returning 39 a value when dereferenced and being incrementable), or be off-the-end 40 (and not dereferenceable or incrementable).</p> 41</div> 42<div class="refsect1"> 43<a name="id-1.3.49.3.6.4"></a><h2>Associated types</h2> 44<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "> 45<li class="listitem"> 46<p><span class="bold"><strong>value_type</strong></span></p> 47<pre class="literallayout">std::iterator_traits<Iter>::value_type</pre> 48<p>The stated value type of the iterator (should be 49 <code class="computeroutput">void</code> for an output iterator that does not model some other 50 iterator concept).</p> 51</li> 52<li class="listitem"> 53<p><span class="bold"><strong>difference_type</strong></span></p> 54<pre class="literallayout">std::iterator_traits<Iter>::difference_type</pre> 55<p>The difference type of the iterator</p> 56</li> 57<li class="listitem"> 58<p><span class="bold"><strong>category</strong></span></p> 59<pre class="literallayout">std::iterator_traits<Iter>::iterator_category</pre> 60<p>The category of the iterator</p> 61</li> 62</ul></div> 63</div> 64<div class="refsect1"> 65<a name="id-1.3.49.3.6.5"></a><h2>Notation</h2> 66<div class="variablelist"><dl class="variablelist"> 67<dt><span class="term">Iter</span></dt> 68<dd>A type playing the role of iterator-type in the <a class="link" href="OutputIterator.html" title="Concept OutputIterator">OutputIterator</a> concept.</dd> 69<dt><span class="term">ValueType</span></dt> 70<dd>A type playing the role of value-type in the <a class="link" href="OutputIterator.html" title="Concept OutputIterator">OutputIterator</a> concept.</dd> 71<dt> 72<span class="term"><code class="varname">i</code>, </span><span class="term"><code class="varname">j</code></span> 73</dt> 74<dd>Objects of type Iter</dd> 75<dt><span class="term"><code class="varname">x</code></span></dt> 76<dd>Object of type ValueType</dd> 77</dl></div> 78</div> 79<div class="refsect1"> 80<a name="id-1.3.49.3.6.6"></a><h2>Type expressions</h2> 81<div class="variablelist"><dl class="variablelist"> 82<dt><span class="term"></span></dt> 83<dd><p>The type <span class="type">Iter</span> must be a model of <a class="link" href="Assignable.html" title="Concept Assignable">Assignable</a>.</p></dd> 84<dt><span class="term"></span></dt> 85<dd><p>The type <span class="type">ValueType</span> must be a model of <a class="link" href="Assignable.html" title="Concept Assignable">Assignable</a>.</p></dd> 86<dt><span class="term"></span></dt> 87<dd><p>The type <span class="type">Iter</span> must be a model of <a class="link" href="DefaultConstructible.html" title="Concept DefaultConstructible">DefaultConstructible</a>.</p></dd> 88<dt><span class="term"></span></dt> 89<dd><p>The type <span class="type">Iter</span> must be a model of 90 <a class="link" href="EqualityComparable.html" title="Concept EqualityComparable">EqualityComparable</a>.</p></dd> 91<dt><span class="term">Category tag</span></dt> 92<dd><p><span class="type">category</span> must be 93 derived from <span class="type">std::output_iterator_tag</span>, a model of <a class="link" href="DefaultConstructible.html" title="Concept DefaultConstructible">DefaultConstructible</a>, and a model of <a class="link" href="CopyConstructible.html" title="Concept CopyConstructible">CopyConstructible</a>. 94 </p></dd> 95<dt><span class="term">Difference type properties</span></dt> 96<dd><p><span class="type">difference_type</span> must be 97 a model of <a class="link" href="SignedInteger.html" title="Concept SignedInteger">SignedInteger</a>. 98 </p></dd> 99</dl></div> 100</div> 101<div class="refsect1"> 102<a name="id-1.3.49.3.6.7"></a><h2>Valid expressions</h2> 103<div class="informaltable"><table class="table"> 104<colgroup> 105<col> 106<col> 107<col> 108<col> 109<col> 110<col> 111</colgroup> 112<thead><tr> 113<th>Name</th> 114<th>Expression</th> 115<th>Type</th> 116<th>Precondition</th> 117<th>Semantics</th> 118<th>Postcondition</th> 119</tr></thead> 120<tbody> 121<tr> 122<td><p>Dereference</p></td> 123<td><p>*i</p></td> 124<td><p></p></td> 125<td><p><code class="computeroutput">i</code> is incrementable (not 126 off-the-end)</p></td> 127<td> </td> 128<td> </td> 129</tr> 130<tr> 131<td><p>Dereference and assign</p></td> 132<td><p>*i = x</p></td> 133<td><p></p></td> 134<td><p><code class="computeroutput">i</code> is incrementable (not 135 off-the-end)</p></td> 136<td> </td> 137<td><p><code class="computeroutput">*i</code> may not be written to again until it has 138 been incremented.</p></td> 139</tr> 140<tr> 141<td><p>Preincrement</p></td> 142<td><p>++i</p></td> 143<td><p><span class="type">Iter &</span></p></td> 144<td><p><code class="computeroutput">i</code> is incrementable (not 145 off-the-end)</p></td> 146<td> </td> 147<td> </td> 148</tr> 149<tr> 150<td><p>Postincrement</p></td> 151<td><p>i++</p></td> 152<td><p></p></td> 153<td><p><code class="computeroutput">i</code> is incrementable (not 154 off-the-end)</p></td> 155<td><p>Equivalent to <code class="computeroutput">(void)(++i)</code></p></td> 156<td><p><code class="computeroutput">i</code> is dereferenceable or 157 off-the-end</p></td> 158</tr> 159<tr> 160<td><p>Postincrement, dereference, and assign</p></td> 161<td><p>*i++ = x</p></td> 162<td><p></p></td> 163<td><p><code class="computeroutput">i</code> is incrementable (not 164 off-the-end)</p></td> 165<td><p>Equivalent to <code class="computeroutput">{*i = t; ++i;}</code></p></td> 166<td><p><code class="computeroutput">i</code> is dereferenceable or 167 off-the-end</p></td> 168</tr> 169</tbody> 170</table></div> 171</div> 172<div class="refsect1"> 173<a name="id-1.3.49.3.6.8"></a><h2>Complexity</h2> 174<p> 175 All iterator operations must take amortized constant time. 176 </p> 177</div> 178<div class="refsect1"> 179<a name="id-1.3.49.3.6.9"></a><h2>Models</h2> 180<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "> 181<li class="listitem"><span class="simplelist"><span class="type">std::ostream_iterator</span>, <span class="type">...</span></span></li> 182<li class="listitem"><span class="simplelist"><span class="type">std::insert_iterator</span>, <span class="type">...</span></span></li> 183<li class="listitem"><span class="simplelist"><span class="type">std::front_insert_iterator</span>, <span class="type">...</span></span></li> 184<li class="listitem"><span class="simplelist"><span class="type">std::back_insert_iterator</span>, <span class="type">...</span></span></li> 185</ul></div> 186</div> 187</div> 188<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr> 189<td align="left"></td> 190<td align="right"><div class="copyright-footer">Copyright © 2001, 2002 Indiana University<br>Copyright © 2000, 2001 University of Notre Dame du Lac<br>Copyright © 2000 Jeremy Siek, Lie-Quan Lee, Andrew Lumsdaine<br>Copyright © 1996-1999 Silicon Graphics Computer Systems, Inc.<br>Copyright © 1994 Hewlett-Packard Company<p>Distributed under the Boost Software License, Version 1.0. 191 (See accompanying file <code class="filename">LICENSE_1_0.txt</code> or copy at 192 <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>) 193 </p> 194<p>This product includes software developed at the University 195 of Notre Dame and the Pervasive Technology Labs at Indiana 196 University. For technical information contact Andrew Lumsdaine 197 at the Pervasive Technology Labs at Indiana University. For 198 administrative and license questions contact the Advanced 199 Research and Technology Institute at 351 West 10th Street. 200 Indianapolis, Indiana 46202, phone 317-278-4100, fax 201 317-274-5902.</p> 202<p>Some concepts based on versions from the MTL draft manual 203 and Boost Graph and Property Map documentation, the SGI Standard 204 Template Library documentation and the Hewlett-Packard STL, 205 under the following license: 206 </p> 207<div class="blockquote"><blockquote class="blockquote"><p>Permission to use, copy, modify, distribute and 208 sell this software and its documentation for any purpose is 209 hereby granted without fee, provided that the above copyright 210 notice appears in all copies and that both that copyright 211 notice and this permission notice appear in supporting 212 documentation. Silicon Graphics makes no representations 213 about the suitability of this software for any purpose. It is 214 provided "as is" without express or implied 215 warranty.</p></blockquote></div> 216</div></td> 217</tr></table> 218<hr> 219<div class="spirit-nav"> 220<a accesskey="p" href="InputIterator.html"><img src="../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="concept_check.html#concepts.reference"><img src="../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="index.html"><img src="../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="ForwardIterator.html"><img src="../../doc/src/images/next.png" alt="Next"></a> 221</div> 222</body> 223</html> 224