std::flat_set::emplace(3)
β¨ std::flat_set::emplace β¨
okay so bestie, welcome to std::flat_set::emplace(3) from the C++ Standard Libary manual β yes, the manual name is folded in right here, cute and accounted for. this is the group chat for inserting one (1) element into a std::flat_set, and it's giving iconic container energy. π
πΈ NAME πΈ
std::flat_set::emplace β literally std::flat_set::emplace. that's the name, bestie, no cap. π
β¨ Synopsis β¨
template< class... Args > (since C++23)
std::pair<iterator, bool> emplace( Args&&... args );
Inserts a new element into the container constructed in-place with the given args, if there is no element with the key in the container. slay. β¨
First, 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));
This overload participates in overload resolution only if std::is_constructible_v<value_type, Args...> is true. that's the vibe check for this overload, periodt. π
Careful use of emplace allows the new element to be constructed while avoiding unnecessary copy or move operations. highkey the whole point. π«Ά
Information on iterator invalidation is copied from here β yes, that's the actual tea, copied from there. π¦
π Parameters π
argsβ arguments to forward to the constructor of the element.
π Return value π
A pair consisting of an iterator to the inserted element (or to the element that prevented the insertion) and a bool value set to true if and only if the insertion took place. so: iterator + yes/no, bestie. β
π₯ Exceptions π₯
If an exception is thrown for any reason, this function has no effect (strong exception safety guarantee). dramatic? yes. but also safe? also yes. π
π§ Complexity π§
Logarithmic in the size of the container. log-time, no cap. π
π Example π
This section is incomplete. Reason: no example. the example slot is literally empty, and we're all just gonna have to deal. π
π See also π
emplace_hintβ constructs elements in-place using a hint (public member function).insertβ inserts elements (public member function).
π·οΈ Category π·οΈ
Todo no example
signed off with love by cppreference.com, dated 2024.06.10, for std::flat_set::emplace(3) β mwah πβ¨
π¦ 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