STD::_DEQUE_BASE(3)
π¦ NAME π¦
okay bestie, gather round, it's a section 3 Library Functions Manual situation and the star of the show is std::_Deque_base< _Tp, _Alloc > π
β¨ SYNOPSIS β¨
#include <deque>
Inherited by std::deque< _Tp, polymorphic_allocator< _Tp > > [protected], and std::deque< _Tp, _Alloc > [protected].
So yeah, it's the momager of deque β the deque classes inherit from it, but only on the protected side, iykyk π₯
π Protected Types π
enum { _S_initial_map_size }β a lil anonymous enum, it's giving "starting map size" energy β¨typedef __gnu_cxx::__alloc_traits< _Tp_alloc_type > _Alloc_traitsβ traits for the element allocator, iconictypedef __gnu_cxx::__alloc_traits< _Map_alloc_type > _Map_alloc_traitsβ same deal but for the map allocator πΊοΈtypedef _Alloc_traits::template rebind< _Ptr >::other _Map_alloc_typeβ rebinding_Alloc_traitsto_Ptrso we get the map allocator type πtypedef iterator::_Map_pointer _Map_pointerβ literally just borrowing the pointer type offiteratortypedef _Alloc_traits::pointer _Ptrβ the pointer type, no notestypedef _Alloc_traits::const_pointer _Ptr_constβ the const pointer type, the responsible sibling π«Άtypedef __gnu_cxx::__alloc_traits< _Alloc >::template rebind< _Tp >::other _Tp_alloc_typeβ rebinding your_Allocto_Tp, so the base can talk about elements β¨typedef _Alloc allocator_typeβ the allocator, but make it officialtypedef _Deque_iterator< _Tp, const _Tp &, _Ptr_const > const_iteratorβ a const iterator, slaytypedef _Deque_iterator< _Tp, _Tp &, _Ptr > iteratorβ a regular iterator, also slay
π§ Protected Member Functions π§
_Deque_base (_Deque_base &&__x)β move constructor, taking__xπ«_Deque_base (_Deque_base &&__x, const allocator_type &__a)β move constructor, but you also hand over an allocator__a_Deque_base (_Deque_base &&__x, const allocator_type &__a, size_t __n)β move constructor with an allocator__aand a size__n, main character behavior fr_Deque_base (const allocator_type &__a)β constructor from just an allocator__a_Deque_base (const allocator_type &__a, size_t __num_elements)β allocator__aplus__num_elementsβ¨_Deque_base (size_t __num_elements)β just a count of elements, that's it, that's the whole vibe_Map_pointer _M_allocate_map (size_t __n)β allocates the map,__nof it πΊοΈ_Ptr _M_allocate_node ()β allocates a single node, no args, no drama πvoid _M_create_nodes (_Map_pointer __nstart, _Map_pointer __nfinish)β builds nodes from__nstartto__nfinishπ₯void _M_deallocate_map (_Map_pointer __p, size_t __n) noexceptβ frees the map at__p,__nbig, and it'snoexceptso it will not throw at you π«Άvoid _M_deallocate_node (_Ptr __p) noexceptβ frees one node at__p, alsonoexcept, also unbotheredvoid _M_destroy_nodes (_Map_pointer __nstart, _Map_pointer __nfinish) noexceptβ destroys nodes__nstartβ__nfinish,noexceptofc π_Map_alloc_type _M_get_map_allocator () const noexceptβ hands you the map allocator,const,noexcept, perfectconst _Tp_alloc_type & _M_get_Tp_allocator () const noexceptβ the const ref flavor of the element allocator getter_Tp_alloc_type & _M_get_Tp_allocator () noexceptβ the non-const flavor, for when you need to actually touch it πvoid _M_initialize_map (size_t)β Layout storage. (more on this queen below β¬οΈ)allocator_type get_allocator () const noexceptβ gives you back the allocator,constandnoexceptbecause of course π
π«Ά Protected Attributes π«Ά
_Deque_impl _M_implβ the one and only member, the whole implementation living in one lil field π
π Detailed Description π
template<typename _Tp, typename _Alloc>
class std::_Deque_base< _Tp, _Alloc >
okay so this is the Deque base class π
It's the unified face for deque's allocation β like, deque's whole memory situation gets one consistent front-end and this is it.
Its constructor and destructor allocate and deallocate storage, but they do not initialize it. And the reason is honestly so valid: it makes exception safety easier β¨
Now listen, because this part is important: nothing in this class ever constructs or destroys an actual Tp element. Not once. Deque handles that itself, bestie. This class is purely the memory-management department β only/all memory management is performed here. That's the job. That's the whole job π
π Member Function Documentation π
_M_initialize_map
template<typename _Tp, typename _Alloc> void std::_Deque_base< _Tp, _Alloc
>::_M_initialize_map (size_t __num_elements) [protected]
Layout storage. β¨
Parameters
__num_elementsβ the count ofT's for which to allocate space at first.
The initial underlying memory layout is a bit complicated...
(that's a direct quote, and honestly? it's giving "don't worry about it" π)
References std::max().
πΈ Author πΈ
Generated automatically by Doxygen for libstdc++ from the source code. π¦
and that's the whole page bestie, no cap β this was std::_Deque_base< _Tp, _Alloc > from the libstdc++ Library Functions Manual (section 3), auto-generated by Doxygen straight from the source code. go forth and manage your memory responsibly, mwah πππ
π¦ 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.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