STD::_DEQUE_ITERATOR(3)
β¨ NAME β¨
std::_Deque_iterator< _Tp, _Ref, _Ptr > β bestie, it's a deque::iterator. That's the whole vibe. π¦
This is one of those libstdc++ internals pages, living in the Library Functions Manual (section 3, iykyk), and honestly? It's the engine room of std::deque. Come with me. π
πΈ SYNOPSIS πΈ
First thing, the golden rule of getting to know this girl:
#include <deque>
That's it. That's the entry point. She lives in <deque>. π
π Public Types π
typedef __ptr_rebind< _Ptr, _Tp >_Elt_pointerβ a pointer, but rebranded to point at the element type. glow-up π«typedef __ptr_rebind< _Ptr, _Elt_pointer >_Map_pointerβ a pointer to pointers, aka the map of nodes. it's giving "pointer to the pointer store".typedef _Deque_iterator_Selfβ she refers to herself. main character energy, literally. πtypedef __iter< const _Tp >const_iteratorβ the read-only version, no touching.typedef ptrdiff_tdifference_typeβ the number type used for distances between iterators.typedef __iter< _Tp >iteratorβ the regular, can-edit-everything version.typedef std::random_access_iterator_tagiterator_categoryβ bestie she's a random access iterator, the most powerful category. she can jump around, no cap. π₯typedef _Ptrpointerβ plain pointer typedef.typedef _Refreferenceβ plain reference typedef.typedef size_tsize_typeβ size things.typedef _Tpvalue_typeβ the element type itself.
π Public Member Functions π
_Deque_iterator (_Elt_pointer __x, _Map_pointer __y) noexceptβ constructor from an element pointer plus a map pointer._Deque_iterator (const _Deque_iterator &__x) noexceptβ copy constructor,noexcept, chill as ever.template<typename _Iter, typename = _Require<is_same<_Self, const_iterator>, is_same<_Iter, iterator>>> _Deque_iterator (const _Iter &__x) noexceptβ converting constructor, only enabled when_Selfisconst_iteratorand_Iterisiterator. so:iteratorβconst_iterator, but never the other way round. as it should be. πiterator _M_const_cast () const noexceptβ casts away const-ness and hands you a plainiterator. sneaky but it's right there in the name.void _M_set_node (_Map_pointer __new_node) noexceptβ get ready to traverse__new_node. (More on her below. β)reference operator* () const noexceptβ dereference, you get the element. the classic._Self & operator++ () noexceptβ pre-increment. move forward one. β‘οΈ_Self operator++ (int) noexceptβ post-increment. returns the old you, then moves on. character development._Self & operator+= (difference_type __n) noexceptβ jump forward__n. zoom zoom._Self & operator-- () noexceptβ pre-decrement. back it up. β¬ οΈ_Self operator-- (int) noexceptβ post-decrement, old copy first._Self & operator-= (difference_type __n) noexceptβ jump back__n.pointer operator-> () const noexceptβ member access through the iterator._Deque_iterator & operator= (const _Deque_iterator &) = defaultβ copy assignment, and it's just the compiler default. she said "no custom logic today". πreference operator[] (difference_type __n) const noexceptβ random access subscripting, because she's a random access iterator and she EARNED it.
π Static Public Member Functions π
static size_t _S_buffer_size () noexceptβ the buffer size, as a static. it's a class-level secret.
π«Ά Public Attributes π«Ά
_Elt_pointer _M_curβ where you're currently pointing._Elt_pointer _M_firstβ start of the current buffer._Elt_pointer _M_lastβ end of the current buffer._Map_pointer _M_nodeβ the map node this iterator is sitting on.
Four little fields, doing a LOT of heavy lifting. π
β Friends β
These are the free functions that get to touch her privates (compiler-speak for it, not my words π):
_Self operator+ (const _Self &__x, difference_type __n) noexceptβ iterator plus offset._Self operator+ (difference_type __n, const _Self &__x) noexceptβ offset plus iterator, the commutative twin.template<typename _RefR, typename _PtrR> difference_type operator- (const _Self &__x, const _Deque_iterator< _Tp, _RefR, _PtrR > &__y) noexceptβ distance between two iterators, even when their_Ref/_Ptrdiffer.difference_type operator- (const _Self &__x, const _Self &__y) noexceptβ distance between two identical-typed iterators._Self operator- (const _Self &__x, difference_type __n) noexceptβ iterator minus offset.strong_ordering operator<=> (const _Self &__x, const _Self &__y) noexceptβ the three-way spaceship comparison. π iconic.template<typename _RefR, typename _PtrR> bool operator== (const _Self &__x, const _Deque_iterator< _Tp, _RefR, _PtrR > &__y) noexceptβ equality across differing_Ref/_Ptr.bool operator== (const _Self &__x, const _Self &__y) noexceptβ equality, same types.
π Detailed Description π
template<typename _Tp, typename _Ref, typename _Ptr>
struct std::_Deque_iterator< _Tp, _Ref, _Ptr >
Okay so, per the docs: it's a deque::iterator.
And the description is genuinely obsessed with itself, and honestly, correctly:
Quite a bit of intelligence here. Much of the functionality of deque is actually passed off to this class. A deque holds two of these internally, marking its valid range. Access to elements is done as offsets of either of those two, relying on operator overloading in this class.
Translation, bestie: a lot of brain lives in this iterator. deque outsources a huge chunk of its whole personality to this one class. The container keeps two of these inside it at all times, and those two mark the valid range. When you want an element, it's all offsets from one of those two, and the operator overloading in here is what makes that work. π§
All the functions are op overloads except for _M_set_node.
That's the whole function list accounted for, fr fr. Every single one is an operator overload except _M_set_node. periodt.
π₯ Member Function Documentation π₯
_M_set_node
template<typename _Tp, typename _Ref, typename _Ptr> void
std::_Deque_iterator< _Tp, _Ref, _Ptr >::_M_set_node (_Map_pointer
__new_node) [inline], [noexcept]
She's [inline] and [noexcept], and what she does is: prepares to traverse __new_node.
Here's the important bit, don't skip it: she sets everything except _M_cur. So the caller has to set _M_cur themselves, immediately afterwards, and they figure out the right value based on _M_first and _M_last.
So if you ever call this yourself: set _M_cur right after, or you're just vibing in an uninitialised iterator. π
π· Author π·
Generated automatically by Doxygen for libstdc++ from the source code.
And that's the whole page, bestie β every typedef, every overload, every friend, every field, all accounted for. π
Cute little sign-off before you go: this absolute queen of a page comes to you from libstdc++, the C++ standard library implementation, as rendered by Doxygen, and it sits in the Library Functions Manual as std::_Deque_iterator< _Tp, _Ref, _Ptr >(3). Go forth and index responsibly. π«Άβ¨
π¦ 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