std::map upper_bound() method
- since C++14
- since C++98
// (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 of the elements to countx
- a value of any type that can be transparently compared with a 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_associative_lookup
(for overloads (3) and (4)).
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.