std::deque::push_back(3)
π std::deque::push_back(3) π
π NAME π
std::deque::push_back - std::deque::push_back β bestie, this is the C++ Standard Libary manual page for std::deque::push_back, section 3, and it's here to explain the whole append-to-the-end situation π
.
πΈ Synopsis πΈ
void push_back( const T& value ); (1)
void push_back( T&& value ); (2) (since C++11)
It appends the given element value to the end of the container β literally yeeting it onto the end π«Ά.
- The new element is initialized as a copy of
value. valueis moved into the new element.
All iterators β including the end() iterator β are invalidated. No references are invalidated. No cap.
π Parameters π
valueβ the value of the element to append.
π¦ Type requirements π¦
Tmust meet the requirements of CopyInsertable in order to use overload (1).Tmust meet the requirements of MoveInsertable in order to use overload (2).
π Return value π
(none) β nothing comes back, bestie π. It's giving void energy.
π₯ Complexity π₯
Constant. Periodt. β¨
π Exceptions π
If an exception is thrown β and that can be due to Allocator::allocate() or element copy/move constructor/assignment β this function has no effect. That's the strong exception guarantee, and yes it's giving safety π
.
β¨ Example β¨
// Run this code
#include <iomanip>
#include <iostream>
#include <string>
#include <deque>
int main()
{
std::deque<std::string> letters;
letters.push_back("abc");
std::string s{"def"};
letters.push_back(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: "abc" "def"
Moved-from string s holds: ""
π See also π
emplace_backβ constructs an element in-place at the end. (C++11) (public member function)push_frontβ inserts an element to the beginning. (public member function)pop_backβ removes the last element. (public member function)back_inserterβ creates astd::back_insert_iteratorof type inferred from the argument. (function template)
okay that's the whole page! π source: http://cppreference.com β version/date: 2024.06.10 β page: std::deque::push_back(3) π«Άβ¨
π¦ 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