• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1<?xml version="1.0" encoding="utf-8" ?>
2<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
4<head>
5<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
6<meta name="generator" content="Docutils 0.7: http://docutils.sourceforge.net/" />
7<title>The MPL Reference Manual: Forward Sequence</title>
8<link rel="stylesheet" href="../style.css" type="text/css" />
9</head>
10<body class="docframe refmanual">
11<table class="header"><tr class="header"><td class="header-group navigation-bar"><span class="navigation-group"><a href="./concepts.html" class="navigation-link">Prev</a>&nbsp;<a href="./bidirectional-sequence.html" class="navigation-link">Next</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group">Back&nbsp;<a href="./bidirectional-sequence.html" class="navigation-link">Along</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./concepts.html" class="navigation-link">Up</a>&nbsp;<a href="../refmanual.html" class="navigation-link">Home</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./refmanual_toc.html" class="navigation-link">Full TOC</a></span></td>
12<td class="header-group page-location"><a href="../refmanual.html" class="navigation-link">Front Page</a> / <a href="./sequences.html" class="navigation-link">Sequences</a> / <a href="./concepts.html" class="navigation-link">Concepts</a> / <a href="./forward-sequence.html" class="navigation-link">Forward Sequence</a></td>
13</tr></table><div class="header-separator"></div>
14<div class="section" id="forward-sequence">
15<h1><a class="toc-backref" href="./concepts.html#id1395">Forward Sequence</a></h1>
16<div class="section" id="description">
17<h3>Description</h3>
18<p>A <a class="reference internal" href="./forward-sequence.html">Forward Sequence</a> is an MPL concept representing a compile-time sequence of
19elements. Sequence elements are
20types, and are accessible through <a class="reference internal" href="./iterators.html">Iterators</a>. The <a class="reference internal" href="./begin.html">begin</a> and <a class="reference internal" href="./end.html">end</a> metafunctions
21provide iterators delimiting the range of the sequence
22elements.  A sequence guarantees that its elements are arranged in a definite,
23but possibly unspecified, order. Every MPL sequence is a <a class="reference internal" href="./forward-sequence.html">Forward Sequence</a>.</p>
24</div>
25<div class="section" id="definitions">
26<h3>Definitions</h3>
27<ul class="simple">
28<li>The <em>size</em> of a sequence is the number of elements it contains. The size is a
29nonnegative number.</li>
30<li>A sequence is <em>empty</em> if its size is zero.</li>
31</ul>
32</div>
33<div class="section" id="expression-requirements">
34<h3>Expression requirements</h3>
35<p>For any <a class="reference internal" href="./forward-sequence.html">Forward Sequence</a> <tt class="literal"><span class="pre">s</span></tt> the following expressions must be valid:</p>
36<table border="1" class="docutils table">
37<colgroup>
38<col width="30%" />
39<col width="39%" />
40<col width="30%" />
41</colgroup>
42<thead valign="bottom">
43<tr><th class="head">Expression</th>
44<th class="head">Type</th>
45<th class="head">Complexity</th>
46</tr>
47</thead>
48<tbody valign="top">
49<tr><td><tt class="literal"><span class="pre"><a href="./begin.html" class="identifier">begin</a>&lt;s&gt;::type</span></tt></td>
50<td><a class="reference internal" href="./forward-iterator.html">Forward Iterator</a></td>
51<td>Amortized constant time</td>
52</tr>
53<tr><td><tt class="literal"><span class="pre"><a href="./end.html" class="identifier">end</a>&lt;s&gt;::type</span></tt></td>
54<td><a class="reference internal" href="./forward-iterator.html">Forward Iterator</a></td>
55<td>Amortized constant time</td>
56</tr>
57<tr><td><tt class="literal"><span class="pre"><a href="./size.html" class="identifier">size</a>&lt;s&gt;::type</span></tt></td>
58<td><a class="reference internal" href="./integral-constant.html">Integral Constant</a></td>
59<td>Unspecified</td>
60</tr>
61<tr><td><tt class="literal"><span class="pre"><a href="./empty.html" class="identifier">empty</a>&lt;s&gt;::type</span></tt></td>
62<td>Boolean <a class="reference internal" href="./integral-constant.html">Integral Constant</a></td>
63<td>Constant time</td>
64</tr>
65<tr><td><tt class="literal"><span class="pre"><a href="./front.html" class="identifier">front</a>&lt;s&gt;::type</span></tt></td>
66<td>Any type</td>
67<td>Amortized constant time</td>
68</tr>
69</tbody>
70</table>
71</div>
72<div class="section" id="expression-semantics">
73<h3>Expression semantics</h3>
74<table border="1" class="docutils table">
75<colgroup>
76<col width="28%" />
77<col width="72%" />
78</colgroup>
79<thead valign="bottom">
80<tr><th class="head">Expression</th>
81<th class="head">Semantics</th>
82</tr>
83</thead>
84<tbody valign="top">
85<tr><td><tt class="literal"><span class="pre"><a href="./begin.html" class="identifier">begin</a>&lt;s&gt;::type</span></tt></td>
86<td>An iterator to the first element of the sequence; see <a class="reference internal" href="./begin.html">begin</a>.</td>
87</tr>
88<tr><td><tt class="literal"><span class="pre"><a href="./end.html" class="identifier">end</a>&lt;s&gt;::type</span></tt></td>
89<td>A past-the-end iterator to the sequence; see <a class="reference internal" href="./end.html">end</a>.</td>
90</tr>
91<tr><td><tt class="literal"><span class="pre"><a href="./size.html" class="identifier">size</a>&lt;s&gt;::type</span></tt></td>
92<td>The size of the sequence; see <a class="reference internal" href="./size.html">size</a>.</td>
93</tr>
94<tr><td><tt class="literal"><span class="pre"><a href="./empty.html" class="identifier">empty</a>&lt;s&gt;::type</span></tt></td>
95<td>A boolean <a class="reference internal" href="./integral-constant.html">Integral Constant</a> <tt class="literal"><span class="pre">c</span></tt> such that
96<tt class="literal"><span class="pre">c::value</span> <span class="pre">==</span> <span class="pre">true</span></tt> if and only if the sequence is empty; see <a class="reference internal" href="./empty.html">empty</a>.</td>
97</tr>
98<tr><td><tt class="literal"><span class="pre"><a href="./front.html" class="identifier">front</a>&lt;s&gt;::type</span></tt></td>
99<td>The first element in the sequence; see <a class="reference internal" href="./front.html">front</a>.</td>
100</tr>
101</tbody>
102</table>
103</div>
104<div class="section" id="invariants">
105<h3>Invariants</h3>
106<p>For any <a class="reference internal" href="./forward-sequence.html">Forward Sequence</a> <tt class="literal"><span class="pre">s</span></tt> the following invariants always hold:</p>
107<ul class="simple">
108<li>[<tt class="literal"><span class="pre"><a href="./begin.html" class="identifier">begin</a>&lt;s&gt;::type</span></tt>, <tt class="literal"><span class="pre"><a href="./end.html" class="identifier">end</a>&lt;s&gt;::type</span></tt>) is always a valid range.</li>
109<li>An algorithm that iterates through the range [<tt class="literal"><span class="pre"><a href="./begin.html" class="identifier">begin</a>&lt;s&gt;::type</span></tt>, <tt class="literal"><span class="pre"><a href="./end.html" class="identifier">end</a>&lt;s&gt;::type</span></tt>)
110will pass through every element of <tt class="literal"><span class="pre">s</span></tt> exactly once.</li>
111<li><tt class="literal"><span class="pre"><a href="./begin.html" class="identifier">begin</a>&lt;s&gt;::type</span></tt> is identical to <tt class="literal"><span class="pre"><a href="./end.html" class="identifier">end</a>&lt;s&gt;::type</span></tt> if and only if <tt class="literal"><span class="pre">s</span></tt> is empty.</li>
112<li>Two different iterations through <tt class="literal"><span class="pre">s</span></tt> will access its elements in the same order.</li>
113</ul>
114</div>
115<div class="section" id="models">
116<h3>Models</h3>
117<ul class="simple">
118<li><a class="reference internal" href="./vector.html">vector</a></li>
119<li><a class="reference internal" href="./map.html">map</a></li>
120<li><a class="reference internal" href="./range-c.html">range_c</a></li>
121<li><a class="reference internal" href="./iterator-range.html">iterator_range</a></li>
122<li><a class="reference internal" href="./filter-view.html">filter_view</a></li>
123</ul>
124</div>
125<div class="section" id="see-also">
126<h3>See also</h3>
127<p><a class="reference internal" href="./sequences.html">Sequences</a>, <a class="reference internal" href="./bidirectional-sequence.html">Bidirectional Sequence</a>, <a class="reference internal" href="./forward-iterator.html">Forward Iterator</a>, <a class="reference internal" href="./begin.html">begin</a> / <a class="reference internal" href="./end.html">end</a>, <a class="reference internal" href="./size.html">size</a>, <a class="reference internal" href="./empty.html">empty</a>, <a class="reference internal" href="./front.html">front</a></p>
128<!-- Sequences/Concepts//Bidirectional Sequence |20 -->
129</div>
130</div>
131
132<div class="footer-separator"></div>
133<table class="footer"><tr class="footer"><td class="header-group navigation-bar"><span class="navigation-group"><a href="./concepts.html" class="navigation-link">Prev</a>&nbsp;<a href="./bidirectional-sequence.html" class="navigation-link">Next</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group">Back&nbsp;<a href="./bidirectional-sequence.html" class="navigation-link">Along</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./concepts.html" class="navigation-link">Up</a>&nbsp;<a href="../refmanual.html" class="navigation-link">Home</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./refmanual_toc.html" class="navigation-link">Full TOC</a></span></td>
134<td><div class="copyright-footer"><div class="copyright">Copyright ©  2001-2009 Aleksey Gurtovoy and David Abrahams</div>
135Distributed under the Boost Software License, Version 1.0. (See accompanying
136file LICENSE_1_0.txt or copy at <a class="reference external" href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)</div></td></tr></table></body>
137</html>
138