std::set upper_bound() method
- since C++14
- until C++14
// (1) Non const version
iterator upper_bound( const Key& key );
// (2) Const version
const_iterator upper_bound( const Key& key ) const;
// (3) Non const version
template< class K >
iterator upper_bound( const K& x );
// (4) Const version
template< class K >
const_iterator upper_bound( const K& x ) const;
// (1) Non const version
iterator upper_bound( const Key& key );
// (2) Const version
const_iterator upper_bound( const Key& key ) const;
- (1-2) Returns an iterator pointing to the first element that is greater than
key
. - (3-4) Returns an iterator pointing to the first element that compares greater to the value
x
. This overload participates in overload resolution only if the qualified-idCompare::is_transparent
is valid and denotes a type. It allows calling this function without constructing an instance ofKey
.
Parameters
key
- key value to compare the elements tox
- alternative value that can be compared to Key
Return value
Iterator pointing to the first element that is greater than key.
If no such element is found, a past-the-end iterator (see end()
) is returned.
Complexity
Logarithmic in the size of the container - O(log size()).
Exceptions
(none)
Notes
Feature testing macro: __cpp_lib_generic_unordered_lookup
(for overload (3-4)).
Example
important
This section requires improvement. You can help by editing this doc page.
This article originates from this CppReference page. It was likely altered for improvements or editors' preference. Click "Edit this page" to see all changes made to this document.
Hover to see the original license.
Hover to see the original license.