std::unorde...emplace_hint(3)

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

std::unorde...emplace_hint(3) πŸ’…

okay so this is the C++ Standard Libary page for std::unordered_multimap::emplace_hint, bestie β€” the header title is std::unorde...emplace_hint(3), and we are about to make it make sense ✨.


✨ NAME ✨

std::unordered_multimap::emplace_hint - std::unordered_multimap::emplace_hint. that's the whole name, and yes it's a mouthful, but we love her πŸ’–.

🌸 Synopsis 🌸

the vibe check: this is a template member thingy since C++11, and the signature is exactly:

template< class... Args >                                      (since C++11)
iterator emplace_hint( const_iterator hint, Args&&... args );

okay so what it does: it inserts a new element into the container, using hint as a suggestion where the element should go 🫢.

the constructor of the element type (value_type, that is, std::pair<const Key, T>) is called with exactly the same arguments as supplied to the function, forwarded with std::forward<Args>(args)... ✨.

rehashing tea: if after the operation the new number of elements is greater than old max_load_factor() * bucket_count(), a rehashing takes place πŸ”₯. if rehashing occurs (due to the insertion), all iterators are invalidated. otherwise (no rehashing), iterators are not invalidated. periodt.

πŸŽ€ Parameters πŸŽ€

  • hint β€” iterator, used as a suggestion as to where to insert the new element πŸ‘€.
  • args β€” arguments to forward to the constructor of the element 🎁.

🫢 Return value 🫢

an iterator to the inserted element. lowkey perfect, she's serving exactly what she says πŸ’….

😭 Exceptions 😭

if an exception is thrown for any reason, this function has no effect β€” strong exception safety guarantee, no cap πŸ›‘οΈβœ¨.

πŸ”₯ Complexity πŸ”₯

Amortized constant on average, worst case linear in the size of the container. so usually chill, but bestie do not forget the worst case, highkey πŸ‘‘.

πŸ’€ Example πŸ’€

okay so the example section is literally giving unfinished homework:

This section is incomplete Reason: no example

not me side-eyeing the empty example box πŸ™ˆ.

πŸ‘‘ See also πŸ‘‘

  • emplace β€” constructs element in-place (public member function) πŸ’–.
  • insert β€” inserts elements or nodes (since C++17) (public member function) 🌈.

πŸ“ Category πŸ“

Category: * Todo no example β€” yep, that's the category, and it's giving "we'll finish this later" energy πŸ’€.


okay bye bestie, source/version: http://cppreference.com; date: 2024.06.10; header title: std::unorde...emplace_hint(3) β€” slay and stay safe πŸ’‹βœ¨

πŸ“¦ where this page comes from