std::flat_m...set::emplace(3)
π NAME π
std::flat_multiset::emplace β std::flat_multiset::emplace, bestie. Straight from the C++ Standard Libary manual, and yes, we are keeping the name exactly as it appears. No cap. β¨
πΈ Synopsis πΈ
Okay so hereβs the signature, copied exactly because we do not mess with code, periodt:
template< class... Args > (since C++23)
iterator emplace( Args&&... args );
It inserts a new element into the container, and that element is constructed in-place with the given args. Slay. π
First, it initializes an object t of type value_type with std::forward<Args>(args)..., then inserts t as if by:
auto it = ranges::upper_bound(c, t, compare);
c.insert(it, std::move(t));
Overload-resolution vibe check: this overload participates in overload resolution only if std::is_constructible_v<value_type, Args...> is true. Fr fr.
Careful use of emplace allows the new element to be constructed while avoiding unnecessary copy or move operations. Thatβs the whole point, bestie β careful use is the key word. π
π§ Information on iterator invalidation is copied from here.
π Parameters π
argsβ arguments to forward to the constructor of the element.
π Return value π
An iterator to the inserted element. Thatβs it, thatβs the return value. π«Ά
π«Ά Exceptions π«Ά
If an exception is thrown for any reason, this function has no effect β thatβs the strong exception safety guarantee. Iconic behavior, honestly. π
π₯ Complexity π₯
Logarithmic in the size of the container. Not linear, bestie. Log. π
π Example π
This section is incomplete.
Reason: no example.
Not me staring at an empty example section ππ.
π See also π
emplace_hintβ constructs elements in-place using a hint (public member function).insertβ inserts elements (public member function).
π Category π
Todo no example
Sign-off tea: source/version http://cppreference.com, date 2024.06.10, page std::flat_m...set::emplace(3). Bye bestie, go emplace something cute! πβ¨
π¦ where this page comes from
- nixpkgs unstable: stdman 2024.07.05
- opensuse-leap 16.0: stdman 2024.07.05-bp160.1.9 Β· MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms