[#BloombergLP-bslalg-RbTreeUtil-upperBound-08]
= xref:BloombergLP.adoc[BloombergLP]::xref:BloombergLP/bslalg.adoc[bslalg]::xref:BloombergLP/bslalg/RbTreeUtil.adoc[RbTreeUtil]::upperBound
:relfileprefix: ../../../
:mrdocs:

Return the first node ordered after `value`, or the sentinel&period;

== Synopsis

Declared in `&lt;bslalg&lowbar;rbtreeutil&period;h&gt;`

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;
    class NODE&lowbar;VALUE&lowbar;COMPARATOR,
    class VALUE&gt;
static
xref:BloombergLP/bslalg/RbTreeNode.adoc[RbTreeNode] const*
upperBound(
    xref:BloombergLP/bslalg/RbTreeAnchor.adoc[RbTreeAnchor] const& tree,
    NODE&lowbar;VALUE&lowbar;COMPARATOR& comparator,
    VALUE const& value);
----

== Description

Return the address of the leftmost node holding the smallest value greater&hyphen;than `value` in the specified `tree` (organized according to the specified &apos;comparator) if found, and return `tree&period;sentinel()` if `value` is greater&hyphen;than or equal&hyphen;to the rightmost node in `tree`&period; `COMPARATOR` shall be a functor providing two methods that can be called as if they had the following signatures&colon; &grave; bool operator()(const RbTreeNode&amp;, const VALUE&amp;) const&semi; bool operator()(const VALUE&amp;, const RbTreeNode&amp;) const&semi; &grave; The behavior is undefined unless `comparator` provides a strict weak ordering on objects of type `VALUE`, and `tree` is well&hyphen;formed (`isWellFormed`)&period; Note that this function returns the _last_ position before which `value` could be inserted into `tree` while preserving its ordering&period;

== Return Value

address of the first node ordered after `value`, or the sentinel

== Parameters

[cols="1,4"]
|===
| Name| Description
| *tree*
| tree to search
| *comparator*
| functor used to order nodes against `value`
| *value*
| value whose upper bound is returned
|===


[.small]#Created with https://www.mrdocs.com[MrDocs]#
