STD::BACK_INSERT_ITERATOR(3)

✨ NAME ✨

std::back_insert_iterator< _Container > β€” turns assignment into insertion πŸ’… no cap

This one lives in the Library Functions Manual, bestie, so you know it's the real deal.


πŸ¦‹ SYNOPSIS πŸ¦‹

#include <iterator>

It inherits std::iterator< output_iterator_tag, void, void, void, void >. Periodt.

πŸŽ€ Public Types πŸŽ€

  • typedef _Container container_type β€” a nested typedef for the type of whatever container you used. whatever you brought to the function, basically 🫢
  • using difference_type β€” that's it. that's the whole thing. no blurb provided, she's just there being iconic πŸ’…
  • typedef output_iterator_tag iterator_category β€” one of the tag types.
  • typedef void pointer β€” this type represents a pointer-to-value_type.
  • typedef void reference β€” this type represents a reference-to-value_type.
  • typedef void value_type β€” the type "pointed to" by the iterator.

🌈 Public Member Functions 🌈

  • constexpr back_insert_iterator (_Container &__x) β€” the only way to create this iterator is with a container. that's the whole vibe. no container, no iterator, sorry πŸ₯²
  • constexpr back_insert_iterator & operator* () β€” simply returns *this. literally just hands you back herself. queen behaviour πŸ‘‘
  • constexpr back_insert_iterator & operator++ () β€” simply returns *this. (This iterator does not move.) β€” yes bestie she does NOT move, that's not a bug that's the whole point πŸ’€
  • constexpr back_insert_iterator operator++ (int) β€” simply returns *this. (This iterator does not move.) β€” same energy, postfix flavour ✨
  • constexpr back_insert_iterator & operator= (const typename _Container::value_type &__value)
  • constexpr back_insert_iterator & operator= (typename _Container::value_type &&__value)

πŸ”’ Protected Attributes πŸ”’

  • _Container * container

πŸ’– Detailed Description πŸ’–

template<typename _Container>
class std::back_insert_iterator< _Container >

Turns assignment into insertion. πŸͺ„

These are output iterators, constructed from a container-of-T. Assigning a T to the iterator appends it to the container using push_back. so like, you're not picking a spot, you're just yeeting stuff onto the end, and honestly? valid.

Tip: Using the back_inserter function to create these iterators can save typing. fr fr, save your fingers 🫢

🌸 Member Typedef Documentation 🌸

  • template<typename _Container> typedef _Container std::back_insert_iterator< _Container >::container_type β€” a nested typedef for the type of whatever container you used.
  • typedef output_iterator_tag std::iterator< output_iterator_tag, void, void, void, void >::iterator_category [inherited] β€” one of the tag types.
  • typedef void std::iterator< output_iterator_tag, void, void, void, void >::pointer [inherited] β€” this type represents a pointer-to-value_type.
  • typedef void std::iterator< output_iterator_tag, void, void, void, void >::reference [inherited] β€” this type represents a reference-to-value_type.
  • typedef void std::iterator< output_iterator_tag, void, void, void, void >::value_type [inherited] β€” the type "pointed to" by the iterator.

🧚 Constructor & Destructor Documentation 🧚

  • template<typename _Container> std::back_insert_iterator< _Container >::back_insert_iterator (_Container & __x) [inline], [explicit], [constexpr] β€” the only way to create this iterator is with a container. (yes, she said what she said the first time too.)

References std::__addressof().


πŸ‘‘ Member Function Documentation πŸ‘‘

  • template<typename _Container> back_insert_iterator & std::back_insert_iterator< _Container >::operator* () [inline], [nodiscard], [constexpr] β€” simply returns *this.
  • template<typename _Container> back_insert_iterator & std::back_insert_iterator< _Container >::operator++ () [inline], [constexpr] β€” simply returns *this. (This iterator does not move.).
  • template<typename _Container> back_insert_iterator std::back_insert_iterator< _Container >::operator++ (int ) [inline], [constexpr] β€” simply returns *this. (This iterator does not move.).
  • template<typename _Container> back_insert_iterator & std::back_insert_iterator< _Container >::operator= (const typename _Container::value_type & __value) [inline], [constexpr]

Parameters

  • __value β€” an instance of whatever type container_type::const_reference is; presumably a reference-to-const T for container<T>.

Returns

  • This iterator, for chained operations. slay, chain away πŸ’…

This kind of iterator doesn't really have a position in the container (you can think of the position as being permanently at the end, if you like). Assigning a value to the iterator will always append the value to the end of the container. always. every time. no exceptions bestie, that's just who she is 🌈


πŸ’œ Author πŸ’œ

Generated automatically by Doxygen for libstdc++ from the source code.


okay that's the whole page bestie!! πŸŽ€ go forth and push_back responsibly ✨ β€” this cutie was brought to you by libstdc++, page 3 of the Library Functions Manual, and she ate, no crumbs left πŸŒΈπŸ¦‹πŸ’–

πŸ“¦ where this page comes from
  • arch rolling: gcc 16.2.1+r23+gd564253eb6c8-1 Β· GPL-3.0-or-later WITH GCC-exception-3.1 AND GFDL-1.3-or-later
  • fedora 44: libstdc++-docs 16.0.1-0.10.fc44 Β· GPL-3.0-or-later AND LGPL-3.0-or-later AND (GPL-3.0-or-later WITH GCC-exception-3.1) AND (GPL-3.0-or-later WITH Texinfo-exception) AND (LGPL-2.1-or-later WITH GCC-exception-2.0) AND (GPL-2.0-or-later WITH GCC-exception-2.0) AND (GPL-2.0-or-later WITH GNU-compiler-exception) AND BSL-1.0 AND GFDL-1.3-or-later AND Linux-man-pages-copyleft-2-para AND SunPro AND BSD-1-Clause AND BSD-2-Clause AND BSD-2-Clause-Views AND BSD-3-Clause AND BSD-4-Clause AND BSD-Source-Code AND Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 WITH LLVM-Exception) AND ZPL-2.1 AND ISC AND LicenseRef-Fedora-Public-Domain AND HP-1986 AND curl AND Martin-Birgmeier AND HPND-Markus-Kuhn AND dtoa AND SMLNJ AND AMD-newlib AND OAR AND HPND-merchantability-variant AND HPND-Intel
  • fedora 44: libstdc++-docs 16.2.1-2.fc44
  • fedora 44: libstdc++-docs 16.2.1-3.fc44 Β· GPL-3.0-or-later AND LGPL-3.0-or-later AND (GPL-3.0-or-later WITH GCC-exception-3.1) AND (GPL-3.0-or-later WITH Texinfo-exception) AND (LGPL-2.1-or-later WITH GCC-exception-2.0) AND (GPL-2.0-or-later WITH GCC-exception-2.0) AND (GPL-2.0-or-later WITH GNU-compiler-exception) AND BSL-1.0 AND GFDL-1.3-or-later AND Linux-man-pages-copyleft-2-para AND SunPro AND BSD-1-Clause AND BSD-2-Clause AND BSD-2-Clause-Views AND BSD-3-Clause AND BSD-4-Clause AND BSD-Source-Code AND Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 WITH LLVM-Exception) AND ZPL-2.1 AND ISC AND LicenseRef-Fedora-Public-Domain AND HP-1986 AND curl AND Martin-Birgmeier AND HPND-Markus-Kuhn AND dtoa AND SMLNJ AND AMD-newlib AND OAR AND HPND-merchantability-variant AND HPND-Intel
  • πŸ’– girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms