std::deque::emplace_front(3)
π std::deque::emplace_front π
Okay bestie, welcome to the std::deque::emplace_front page from the C++ Standard Libary (yes, thatβs the manual name in the header, spelling and all π
). This is the C++ Standard Library glow-up for putting a brand-new element at the very front of a std::deque.
πΈ NAME πΈ
std::deque::emplace_front β std::deque::emplace_front
π Synopsis
Hereβs the signature tea, exactly as written:
template< class... Args > (since C++11)
void emplace_front( Args&&... args ); (until C++17)
template< class... Args > (since C++17)
reference emplace_front( Args&&... args );
So what does it do? It inserts a new element to the beginning of the container. The element is constructed through std::allocator_traits::construct, which typically uses placement-new to construct the element in-place at the location provided by the container. The arguments args... are forwarded to the constructor as std::forward<Args>(args)....
And the iterator tea? π¨ All iterators (including the end() iterator) are invalidated. No references are invalidated. So your references stay safe, but your iterators are absolutely not coming to the function.
π§Έ Parameters
argsβ arguments to forward to the constructor of the element
π§ Type requirements
T(the container's element type) must meet the requirements ofEmplaceConstructible.
π Return value
(none)β until C++17- A reference to the inserted element. β since C++17
β‘ Complexity
Constant. Short and sweet, no cap.
π Exceptions
If an exception is thrown for any reason, this function has no effect (strong exception safety guarantee). So if it goes wrong, itβs giving βnothing happened hereβ energy. π
π See also
push_frontβ inserts an element to the beginning (public member function)
Source: http://cppreference.com Β· version/date: 2024.06.10 Β· page: std::deque::emplace_front(3) β bye bestie, go emplace responsibly π
β¨
π¦ 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