Files
mpl/doc/ref/Reference/distance.html
Aleksey Gurtovoy a69baa5eae update the docs
[SVN r17836]
2003-03-12 13:29:12 +00:00

56 lines
2.4 KiB
HTML

<!doctype html public "-//ietf//dtd html//en">
<html><head><title>boost::mpl::distance</title>
<link rel="stylesheet" href="../mpl_wiki.css">
</head><body bgcolor="white">
<h1><a href="../Table_of_Contents.html"><img src="../mpl_logo.jpg" alt="[Home]" border=0 align="right"></a>distance</h1><h3>Synopsis</h3>
<p>
<pre>
template&lt;
typename First
, typename Last
&gt;
struct distance
{
typedef <em>unspecified</em> type;
};
</pre>
<p>
<h3>Description</h3>
<p>
Finds the distance between <code>First</code> and <code>Last</code>, that is, an <a href="../Integral_Constant.html">Integral Constant</a> <code>D</code> such as <code>advance&lt; First,D &gt;::type</code> is identical to <code>Last</code>.
<p>
<h3>Definition</h3>
<p>
<pre>
#include "<a href="../../../../../boost/mpl/distance.hpp">boost/mpl/distance.hpp</a>"
</pre>
<p>
<h3>Parameters</h3>
<table border="1">
<tr><th>&nbsp;Parameter&nbsp;</th><th>&nbsp;Requirement&nbsp;</th><th>&nbsp;Description &nbsp;</th></tr>
<tr><td><code>First</code>, <code>Last</code></td><td>A model of <a href="../Input_Iterator.html">Input Iterator</a></td><td></td></tr>
</table>
<p>
<h3>Expression semantics</h3>
<p>
<table border="1">
<tr><th>&nbsp;Expression&nbsp;</th><th>&nbsp;Expression&nbsp;type&nbsp;</th><th>&nbsp;Precondition&nbsp;</th><th>&nbsp;Semantics&nbsp;</th><th>&nbsp;Postcondition&nbsp;</th></tr>
<tr><td><code>typedef distance&lt;First,Last&gt;::type d;</code></td><td>A model of <a href="../Integral_Constant.html">Integral Constant</a></td><td><code>[First, Last)</code> is a valid range</td><td></td><td><code>is_same&lt; advance&lt; First,d &gt;::type, Last &gt;::value</code> </td></tr>
</table>
<p>
<h3>Complexity</h3>
<p>
Amortized constant time if <code>Iterator</code> is a model of <a href="../Random_Access_Iterator.html">Random Access Iterator</a>, otherwise linear time.
<p>
<h3>Example</h3>
<p>
<pre>
typedef range_c&lt;int,0,10&gt;::type range;
BOOST_STATIC_ASSERT((distance&lt; begin&lt;range&gt;::type,end&lt;range&gt;::type &gt;::type::value == 10));
</pre>
<p>
<h3>See also</h3>
<p>
<a href="../Iterators.html">Iterators</a>, <a href="../Sequence.html">Sequence</a>, <code><a href="../Reference/advance.html">advance</a></code>, <code><a href="../Reference/begin.html">begin</a></code>, <code><a href="../Reference/end.html">end</a></code>
<p><hr>
<a href="../Table_of_Contents.html">Table of Contents</a><br>Last edited July 17, 2002 6:47 am</body></html>