std::back_i...::operator=(3)
NAME π
std::back_insert_iterator::operator= β std::back_insert_iterator::operator=. This is the std::back_i...::operator=(3) page from the C++ Standard Libary manual, bestie, and it's all about assigning into a back insert iterator. Periodt.
Synopsis β¨
Okay so the overload lineup is giving timeline energy, and every variant returns a back_insert_iterator<Container>& unless it's the constexpr era one. Here's the whole squad:
back_insert_iterator<Container>&
operator=( typename Container::const_reference value );
(until C++11)
back_insert_iterator<Container>&
operator=( const typename Container::value_type& value );
(since C++11) (until C++20)
constexpr back_insert_iterator<Container>&
operator=( const typename Container::value_type& value );
(1) (since C++20)
back_insert_iterator<Container>&
operator=( typename Container::value_type&& value );
(2) (since C++11) (until C++20)
constexpr back_insert_iterator<Container>&
operator=( typename Container::value_type&& value );
(since C++20)
Inserts the given value value to the container. Yes, the page has that little duplicated βvalueβ moment and we're keeping it, no cap.
- Results in
container->push_back(value). - Results in
container->push_back(std::move(value)).
Parameters π§
valueβ the value to insert.
Return value π
*this β that's it, that's the return. Slay.
Example πΈ
// Run this code π
#include <deque>
#include <iostream>
#include <iterator>
int main()
{
std::deque<int> q;
std::back_insert_iterator<std::deque<int>> it(q);
for (int i = 0; i < 10; ++i)
it = i; // calls q.push_back(i)
for (auto& elem : q)
std::cout << elem << ' ';
std::cout << '\n';
}
Output π₯
0 1 2 3 4 5 6 7 8 9
okay that's the whole page, bestie π«Ά β source/version: http://cppreference.com, date: 2024.06.10, page: std::back_i...::operator=(3). periodt π
π¦ 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