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, iconic
  • typedef __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_traits to _Ptr so we get the map allocator type πŸ’…
  • typedef iterator::_Map_pointer _Map_pointer β€” literally just borrowing the pointer type off iterator
  • typedef _Alloc_traits::pointer _Ptr β€” the pointer type, no notes
  • typedef _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 _Alloc to _Tp, so the base can talk about elements ✨
  • typedef _Alloc allocator_type β€” the allocator, but make it official
  • typedef _Deque_iterator< _Tp, const _Tp &, _Ptr_const > const_iterator β€” a const iterator, slay
  • typedef _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 __a and 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 __a plus __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, __n of 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 __nstart to __nfinish πŸ”₯
  • void _M_deallocate_map (_Map_pointer __p, size_t __n) noexcept β€” frees the map at __p, __n big, and it's noexcept so it will not throw at you 🫢
  • void _M_deallocate_node (_Ptr __p) noexcept β€” frees one node at __p, also noexcept, also unbothered
  • void _M_destroy_nodes (_Map_pointer __nstart, _Map_pointer __nfinish) noexcept β€” destroys nodes __nstart β†’ __nfinish, noexcept ofc πŸ’€
  • _Map_alloc_type _M_get_map_allocator () const noexcept β€” hands you the map allocator, const, noexcept, perfect
  • const _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, const and noexcept because 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 of T'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