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

58 lines
2.6 KiB
HTML

<!doctype html public "-//ietf//dtd html//en">
<html><head><title>boost::mpl::find_if</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>find_if</h1><h3>Synopsis</h3>
<p>
<pre>
template&lt;
typename Sequence
, typename Pred
&gt;
struct find_if
{
typedef <em>unspecified</em> type;
};
</pre>
<p>
<h3>Description</h3>
<p>
Finds the first element in a <code>Sequence</code> that satisfies the predicate <code>Pred</code>.
<p>
<h3>Definition</h3>
<p>
<pre>
#include "<a href="../../../../../boost/mpl/find_if.hpp">boost/mpl/find_if.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>Sequence</code></td><td>A model of <a href="../Forward_Sequence.html">Forward Sequence</a></td><td>A sequence to search in. </td></tr>
<tr><td><code>Pred</code></td><td>A model of Predicate [Lambda Expression]</td><td>A search condition. </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 find_if&lt;Sequence,Pred&gt;::type i;</code></td><td>A model of <a href="../Forward_Iterator.html">Forward Iterator</a></td><td></td><td><code>i</code> is the first iterator in the range <code>[begin&lt;Sequence&gt;::type, end&lt;Sequence&gt;::type)</code> such that <code>apply&lt; lambda&lt;Pred&gt;::type,i::type &gt;::type::value == true</code>; <code>i</code> is identical to <code>end&lt;Sequence&gt;::type</code>, if no such iterator exists.</td><td></td></tr>
</table>
<p>
<h3>Complexity</h3>
<p>
Linear. At most <code>size&lt;Sequence&gt;::value</code> applications of <code>Pred</code>.
<p>
<h3>Example</h3>
<p>
<pre>
typedef <a href="../Reference/vector.html">vector</a>&lt;char,int,unsigned,long,unsigned_long&gt; types;
typedef find_if&lt;types, is_same&lt;_1,unsigned&gt; &gt;::type iter;
BOOST_STATIC_ASSERT(iter::pos::value == 2);
</pre>
<p>
<h3>See also</h3>
<p>
<a href="../Algorithms.html">Algorithms</a>, <code><a href="../Reference/find.html">find</a></code>, <code><a href="../Reference/contains.html">contains</a></code>, <code><a href="../Reference/count.html">count</a></code>, <code><a href="../Reference/count_if.html">count_if</a></code>
<p><hr>
<a href="../Table_of_Contents.html">Table of Contents</a><br>Last edited September 15, 2002 7:24 pm</body></html>