Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: downloads/boost_1_33_1/libs/mpl/doc/refmanual/distance.html @ 12

Last change on this file since 12 was 12, checked in by landauf, 17 years ago

added boost

File size: 8.5 KB
Line 
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.3.6: http://docutils.sourceforge.net/" />
7<title>The MPL Reference Manual: distance</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="./advance.html" class="navigation-link">Prev</a>&nbsp;<a href="./next.html" class="navigation-link">Next</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./advance.html" class="navigation-link">Back</a>&nbsp;<a href="./next.html" class="navigation-link">Along</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./iterator-metafunctions.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="./iterators.html" class="navigation-link">Iterators</a> / <a href="./iterator-metafunctions.html" class="navigation-link">Iterator Metafunctions</a> / <a href="./distance.html" class="navigation-link">distance</a></td>
13</tr></table><div class="header-separator"></div>
14<div class="section" id="distance">
15<h1><a class="toc-backref" href="./iterator-metafunctions.html#id383" name="distance">distance</a></h1>
16<div class="section" id="distance-synopsis">
17<h3><a class="subsection-title" href="#synopsis" name="synopsis">Synopsis</a></h3>
18<pre class="literal-block">
19template&lt;
20      typename First
21    , typename Last
22    &gt;
23struct <a href="./distance.html" class="identifier">distance</a>
24{
25    typedef <em>unspecified</em> type;
26};
27</pre>
28</div>
29<div class="section" id="distance-description">
30<h3><a class="subsection-title" href="#description" name="description">Description</a></h3>
31<p>Returns the distance between <tt class="literal"><span class="pre">First</span></tt> and <tt class="literal"><span class="pre">Last</span></tt> iterators, that is, an
32<a class="reference" href="./integral-constant.html">Integral Constant</a> <tt class="literal"><span class="pre">n</span></tt> such that <tt class="literal"><span class="pre"><a href="./advance.html" class="identifier">advance</a>&lt;First,n&gt;::type</span></tt> is
33identical to <tt class="literal"><span class="pre">Last</span></tt>.</p>
34</div>
35<div class="section" id="distance-header">
36<h3><a class="subsection-title" href="#header" name="header">Header</a></h3>
37<pre class="literal-block">
38#include &lt;<a href="../../../../boost/mpl/distance.hpp" class="header">boost/mpl/distance.hpp</a>&gt;
39</pre>
40</div>
41<div class="section" id="distance-parameters">
42<h3><a class="subsection-title" href="#parameters" name="parameters">Parameters</a></h3>
43<table border="1" class="table">
44<colgroup>
45<col width="19%" />
46<col width="35%" />
47<col width="45%" />
48</colgroup>
49<thead valign="bottom">
50<tr><th>Parameter</th>
51<th>Requirement</th>
52<th>Description</th>
53</tr>
54</thead>
55<tbody valign="top">
56<tr><td><tt class="literal"><span class="pre">First</span></tt>,
57<tt class="literal"><span class="pre">Last</span></tt></td>
58<td><a class="reference" href="./forward-iterator.html">Forward Iterator</a></td>
59<td>Iterators to compute a
60distance between.</td>
61</tr>
62</tbody>
63</table>
64</div>
65<div class="section" id="distance-model-of">
66<h3><a class="subsection-title" href="#model-of" name="model-of">Model Of</a></h3>
67<p><a class="reference" href="./tag-dispatched.html">Tag Dispatched Metafunction</a></p>
68</div>
69<div class="section" id="distance-expression-semantics">
70<h3><a class="subsection-title" href="#expression-semantics" name="expression-semantics">Expression semantics</a></h3>
71<p>For any <a class="reference" href="./forward-iterator.html">Forward Iterator</a>s <tt class="literal"><span class="pre">first</span></tt> and <tt class="literal"><span class="pre">last</span></tt>:</p>
72<pre class="literal-block">
73typedef <a href="./distance.html" class="identifier">distance</a>&lt;first,last&gt;::type n;
74</pre>
75<table class="field-list" frame="void" rules="none">
76<col class="field-name" />
77<col class="field-body" />
78<tbody valign="top">
79<tr class="field"><th class="field-name">Return type:</th><td class="field-body"><a class="reference" href="./integral-constant.html">Integral Constant</a>.</td>
80</tr>
81<tr class="field"><th class="field-name">Precondition:</th><td class="field-body">[<tt class="literal"><span class="pre">first</span></tt>, <tt class="literal"><span class="pre">last</span></tt>) is a valid range.</td>
82</tr>
83<tr class="field"><th class="field-name">Semantics:</th><td class="field-body"><p class="first">Equivalent to</p>
84<pre class="last literal-block">
85typedef <a href="./iter-fold.html" class="identifier">iter_fold</a>&lt;
86      <a href="./iterator-range.html" class="identifier">iterator_range</a>&lt;first,last&gt;
87    , <a href="./long.html" class="identifier">long_</a>&lt;0&gt;
88    , <a href="./next.html" class="identifier">next</a>&lt;_1&gt;
89    &gt;::type n;
90</pre>
91</td>
92</tr>
93<tr class="field"><th class="field-name">Postcondition:</th><td class="field-body"><tt class="literal"><span class="pre">is_same&lt;</span> <span class="pre"><a href="./advance.html" class="identifier">advance</a>&lt;first,n&gt;::type,</span> <span class="pre">last</span> <span class="pre">&gt;::value</span> <span class="pre">==</span> <span class="pre">true</span></tt>.</td>
94</tr>
95</tbody>
96</table>
97</div>
98<div class="section" id="distance-complexity">
99<h3><a class="subsection-title" href="#complexity" name="complexity">Complexity</a></h3>
100<p>Amortized constant time if <tt class="literal"><span class="pre">first</span></tt> and <tt class="literal"><span class="pre">last</span></tt> are <a class="reference" href="./random-access-iterator.html">Random Access Iterator</a>s,
101otherwise linear time.</p>
102</div>
103<div class="section" id="distance-example">
104<h3><a class="subsection-title" href="#example" name="example">Example</a></h3>
105<pre class="literal-block">
106typedef <a href="./range-c.html" class="identifier">range_c</a>&lt;int,0,10&gt;::type range;
107typedef <a href="./begin.html" class="identifier">begin</a>&lt;range&gt;::type first;
108typedef <a href="./end.html" class="identifier">end</a>&lt;range&gt;::type last;
109
110<a href="./assert-relation.html" class="identifier">BOOST_MPL_ASSERT_RELATION</a>( (<a href="./distance.html" class="identifier">distance</a>&lt;first,last&gt;::value), ==, 10);
111</pre>
112</div>
113<div class="section" id="distance-see-also">
114<h3><a class="subsection-title" href="#see-also" name="see-also">See also</a></h3>
115<p><a class="reference" href="./iterators.html">Iterators</a>, <a class="reference" href="./tag-dispatched.html">Tag Dispatched Metafunction</a>, <a class="refentry reference" href="./advance.html"><tt class="refentry literal"><span class="pre">advance</span></tt></a>, <a class="refentry reference" href="./next.html"><tt class="refentry literal"><span class="pre">next</span></tt></a>, <a class="refentry reference" href="./prior.html"><tt class="refentry literal"><span class="pre">prior</span></tt></a></p>
116<!-- modtime: November 11, 2004 11:16:46 +0000 -->
117<!-- Iterators/Iterator Metafunctions//next |30 -->
118</div>
119</div>
120
121<div class="footer-separator"></div>
122<table class="footer"><tr class="footer"><td class="header-group navigation-bar"><span class="navigation-group"><a href="./advance.html" class="navigation-link">Prev</a>&nbsp;<a href="./next.html" class="navigation-link">Next</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./advance.html" class="navigation-link">Back</a>&nbsp;<a href="./next.html" class="navigation-link">Along</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./iterator-metafunctions.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>
123</tr></table></body>
124</html>
Note: See TracBrowser for help on using the repository browser.