std::front_...r::operator=(3)
β¨ std::front_...r::operator=(3) β¨
okay so this one is from the C++ Standard Libary manual (their spelling, not mine π
), and it's all about std::front_insert_iterator::operator= β the assignment operator that literally pushes stuff onto the front. it's giving βoperator= but make it push_frontβ energy πΈ.
β¨ NAME β¨
std::front_insert_iterator::operator= β std::front_insert_iterator::operator=
(yes, the NAME section says it twice. iconic. no notes. π)
πΈ Synopsis πΈ
front_insert_iterator<Container>&
operator=( typename Container::const_reference value ); // (until C++11)
front_insert_iterator<Container>&
operator=( const typename Container::value_type& value ); // (since C++11) (until C++20)
constexpr front_insert_iterator<Container>&
operator=( const typename Container::value_type& value ); // (1) (since C++20)
front_insert_iterator<Container>&
operator=( typename Container::value_type&& value ); // (2) (since C++11) (until C++20)
constexpr front_insert_iterator<Container>&
operator=( typename Container::value_type&& value ); // (since C++20)
lowkey the whole lore: Inserts the given value value to the container. (yes, value twice β we're keeping it exactly as the page says π«Ά).
- Results in
container->push_front(value). - Results in
container->push_front(std::move(value)).
π Parameters π
valueβ the value to insert.
π Return value π
*this β that's the whole return value, bestie. it returns itself. main character energy, periodt β¨.
π§ Example π§
Run this code:
#include <deque>
#include <iostream>
#include <iterator>
int main()
{
std::deque<int> q;
std::front_insert_iterator<std::deque<int>> it(q);
for (int i = 0; i < 10; ++i)
it = i; // calls q.push_front(i)
for (auto& elem : q)
std::cout << elem << ' ';
std::cout << '\n';
}
π Output π
9 8 7 6 5 4 3 2 1 0
source: http://cppreference.com β¨ version/date: 2024.06.10 β¨ page: std::front_...r::operator=(3) β mwah, that's the page, bestie π
π¦ 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