Namespaces
Variants
Views
Actions

std::flat_map<Key,T,Compare,KeyContainer,MappedContainer>::at

From cppreference.com
< cpp‎ | container‎ | flat map
 
 
 
 
T& at( const Key& key );
(1) (since C++23)
const T& at( const Key& key ) const;
(2) (since C++23)
template< class K >
T& at( const K& x );
(3) (since C++23)
template< class K >
const T& at( const K& x ) const;
(4) (since C++23)

Returns a reference to the mapped value of the element with specified key. If no such element exists, an exception of type std::out_of_range is thrown.

1,2) The key is equivalent to key.
3,4) The key compares equivalent to the value x. The reference to the mapped value is obtained as if by expression this->find(x)->second. The expression this->find(x) must be well-formed and has well-defined behavior. This overload participates in overload resolution only if the qualified-id Compare::is_transparent is valid and denotes a type. It allows calling this function without constructing an instance of Key.

Contents

[edit] Parameters

key - the key of the element to find
x - a value of any type that can be transparently compared with a key

[edit] Return value

A reference to the mapped value of the requested element.

[edit] Exceptions

std::out_of_range if the container does not have:

1,2) an element with the specified key.
3,4) the specified element, that is, if find(x) == end() is true.

[edit] Complexity

Logarithmic in the size of the container.

[edit] Example

[edit] See also

access or insert specified element
(public member function) [edit]