std::deque::push_front(3)
π std::deque::push_front π
okay so bestie, welcome to the C++ Standard Libary manual page for std::deque::push_front(3). This one is short, sweet, and honestly kind of a slay: it shoves an element onto the front of a deque. Letβs get into it. β¨
π NAME π
std::deque::push_front - std::deque::push_front
πΈ Synopsis πΈ
void push_front( const T& value ); (1)
void push_front( T&& value ); (2) (since C++11)
Prepends the given element value to the beginning of the container.
π¨ iterator vibe check: all iterators (including the end() iterator) are invalidated. No references are invalidated. So references are fine, iterators are not β periodt.
π«Ά Parameters π«Ά
- value β the value of the element to prepend
β¨ Return value β¨
(none) β it returns nothing, bestie. It just does the front-prepend thing.
π Complexity π
Constant.
π Exceptions π
If an exception is thrown for any reason, these functions have no effect (strong exception safety guarantee).
π¦ Example π¦
// Run this code
#include <deque>
#include <iomanip>
#include <iostream>
#include <string>
int main()
{
std::deque<std::string> letters;
letters.push_front("abc");
std::string s{"def"};
letters.push_front(std::move(s));
std::cout << "std::deque letters holds: ";
for (auto&& e : letters)
std::cout << std::quoted(e) << ' ';
std::cout << "\nMoved-from string s holds: " << std::quoted(s) <<
'\n';
}
π Possible output π
std::deque letters holds: "def" "abc"
Moved-from string s holds: ""
π See also π
emplace_frontβ constructs an element in-place at the beginning (C++11) (public member function)push_backβ adds an element to the end (public member function)pop_frontβ removes the first element (public member function)front_inserterβ creates astd::front_insert_iteratorof type inferred from thefront_inserterargument (function template)
π cute sign-off: source/version/date for this std::deque::push_front(3) page are http://cppreference.com, 2024.06.10 β bye bestie, go prepend something iconic! π
β¨
π¦ 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