std::flat_map::at(3)

πŸ“¦ version 2024.07.05, in nixpkgs unstable, opensuse-leap 16.0

πŸŽ€ std::flat_map::at(3) β€” C++ Standard Libary πŸŽ€

okay bestie, this is the group-chat translation of the std::flat_map::at page, and yes we are keeping every single detail because facts are the main character πŸ’…


🌸 NAME 🌸

std::flat_map::at β€” std::flat_map::at


πŸ¦‹ Synopsis πŸ¦‹

T& at( const Key& key );             (1) (since C++23)
const T& at( const Key& key ) const; (2) (since C++23)
template< class K >                  (3) (since C++23)
T& at( const K& x );
template< class K >                  (4) (since C++23)
const T& at( const K& x ) const;

okay so this function 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 have well-defined behavior, otherwise the behavior is undefined 🚨. Like, do not play with undefined behavior, bestie.
  • These overloads participate 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.

πŸ“ Parameters πŸ“

  • key β€” the key of the element to find
  • x β€” a value of any type that can be transparently compared with a key

πŸ’– Return value πŸ’–

A reference to the mapped value of the requested element. It’s giving β€œhere is your reference” energy 🫢.


πŸ’€ Exceptions πŸ’€

  • 1,2) β€” std::out_of_range if the container does not have an element with the specified key.
  • 3,4) β€” std::out_of_range if the container does not have the specified element, that is, if find(x) == end() is true.

πŸ”₯ Complexity πŸ”₯

Logarithmic in the size of the container. No cap, that’s the complexity 🧚.


🧚 Example 🧚

This section is incomplete.

Reason: no example.


🌈 See also 🌈

  • operator[] β€” access or insert specified element (public member function)

πŸ‘‘ Category πŸ‘‘

  • Todo no example

Source/version/date sign-off: http://cppreference.com, 2024.06.10, std::flat_map::at(3) β€” mwah, bestie πŸ’‹βœ¨

πŸ“¦ where this page comes from