mirror of
https://github.com/boostorg/mpl.git
synced 2026-01-26 17:02:20 +01:00
61 lines
3.1 KiB
HTML
61 lines
3.1 KiB
HTML
<!doctype html public "-//ietf//dtd html//en">
|
|
<html><head><title>boost::mpl::upper_bound</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>upper_bound</h1><h3>Synopsis</h3>
|
|
<p>
|
|
<pre>
|
|
template<
|
|
typename Sequence
|
|
, typename T
|
|
, typename Pred = <a href="../Reference/less.html">less</a><_1,_2>
|
|
>
|
|
struct upper_bound
|
|
{
|
|
typedef <em>unspecified</em> type;
|
|
};
|
|
</pre>
|
|
<p>
|
|
<h3>Description</h3>
|
|
<p>
|
|
Returns the last position in the sorted <code>Sequence</code> where <code>T</code> could be inserted without violating the ordering.
|
|
<p>
|
|
<h3>Definition</h3>
|
|
<p>
|
|
<pre>
|
|
#include "<a href="../../../../../boost/mpl/upper_bound.hpp">boost/mpl/upper_bound.hpp</a>"
|
|
</pre>
|
|
<p>
|
|
<h3>Parameters</h3>
|
|
<table border="1">
|
|
<tr><th> Parameter </th><th> Requirement </th><th> Description </th></tr>
|
|
<tr><td><code>Sequence</code></td><td>A model of <a href="../Forward_Sequence.html">Forward Sequence</a></td><td>A sorted sequence. </td></tr>
|
|
<tr><td><code>T</code></td><td>A type</td><td>A type to search the position for. </td></tr>
|
|
<tr><td><code>Pred</code></td><td>A model of binary Predicate [Lambda Expression]</td><td>A sort criteria. </td></tr>
|
|
</table>
|
|
<p>
|
|
<h3>Expression semantics</h3>
|
|
<p>
|
|
<table border="1">
|
|
<tr><th> Expression </th><th> Expression type </th><th> Precondition </th><th> Semantics </th><th> Postcondition </th></tr>
|
|
<tr><td><code>typedef upper_bound< Sequence,T,Pred >::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 furthermost iterator in <code>[begin<Sequence>::type, end<Sequence>::type)</code> such that, for every iterator <code>j</code> in <code>[begin<Sequence>::type, i)</code>, <code>apply< lambda<Pred>::type, T, j::type >::type::value == false</code>.</td><td></td></tr>
|
|
</table>
|
|
<p>
|
|
<h3>Complexity</h3>
|
|
<p>
|
|
The number of comparisons is logarithmic: at most <code>log(size<Sequence>::type::value) + 1</code>. If <code>Sequence</code> is a <a href="../Random_Access_Sequence.html">Random Access Sequence</a> then the number of steps through the range is also logarithmic; otherwise, the number of steps is proportional to <code>size<Sequence>::type::value</code>.
|
|
<p>
|
|
<h3>Example</h3>
|
|
<p>
|
|
<pre>
|
|
typedef <a href="../Reference/list_c.html">list_c</a><int,1,2,3,3,3,5,8> numbers;
|
|
typedef upper_bound< numbers, int_<3> >::type iter;
|
|
BOOST_STATIC_ASSERT((<a href="../Reference/distance.html">distance</a>< <a href="../Reference/begin.html">begin</a><numbers>::type,iter >::type::value == 5));
|
|
BOOST_STATIC_ASSERT(iter::type::value == 5);
|
|
</pre>
|
|
<p>
|
|
<h3>See also</h3>
|
|
<p>
|
|
<a href="../Algorithms.html">Algorithms</a>, <code>sort</code>, <code><a href="../Reference/lower_bound.html">lower_bound</a></code>
|
|
<p><hr>
|
|
<a href="../Table_of_Contents.html">Table of Contents</a><br>Last edited March 10, 2003 5:44 am</body></html> |