__GNU_CXX::ALLOCATOR(3)

πŸ“¦
version 16.2.1+r23+gd564253eb6c8 Β· 4 versions
, in arch rolling, fedora 44

✨ NAME ✨

__gnu_cxx::allocator< _Tp > β€” bestie, this is the standard allocator, as per C++03 [20.4.1]. That's it, that's the whole vibe.

This page lives in the libstdc++ section of your Library Functions Manual, so like… go off, libstdc++. πŸ’–


πŸŽ€ SYNOPSIS πŸŽ€

Okay so before you can even look at this allocator you gotta do the include, no skipping:

#include <memory>

It inherits std::__new_allocator< _Tp >. Family lineage, we love to see it. πŸ‘‘

🌸 Public Types 🌸

  • typedef ptrdiff_t difference_type β€” the type that measures distances between things, bestie.
  • using propagate_on_container_move_assignment β€” yes, it's a using-declaration and that's literally the whole line, don't come for me.
  • typedef size_t size_type β€” how many. How big. The numbers girlie.
  • typedef _Tp value_type β€” the actual type of the thing you're allocating. The main character.

πŸ’… Public Member Functions πŸ’…

  • constexpr allocator (const allocator &__a) noexcept β€” copy-constructs from another allocator, and it's noexcept so it will never throw at you. periodt.
  • template<typename _Tp1> constexpr allocator (const allocator< _Tp1 > &) noexcept β€” the converting constructor: build one allocator out of a differently typed one. noexcept again, obviously.
  • constexpr _Tp * allocate (size_t __n) β€” hand me __n and I'll hand you back a pointer. simple as.
  • constexpr _Tp * allocate (size_type __n, const void *=static_cast< const void * >(0)) β€” the other allocate, with a second param that defaults to static_cast< const void * >(0). It's giving "we added a parameter for compatibility and gave it a default." 🫢
  • constexpr allocation_result< _Tp *, size_t > allocate_at_least (size_t __n) β€” ask for at least __n, get an allocation_result< _Tp *, size_t > back. "at least" is doing a lot of work in that sentence ngl.
  • constexpr void deallocate (_Tp *__p, size_t __n) β€” give the pointer __p and the size __n back. clean up after yourself, we're not animals. 🧹
  • allocator & operator= (const allocator &)=default β€” the defaulted copy assignment. it's =default, it does what it says on the tin.

🫢 Friends 🫢

  • constexpr bool operator== (const allocator &, const allocator &) noexcept β€” friend of the class, compares two allocators, constexpr and noexcept. bestie behavior.

(Note that these are not member symbols. Okay? They're related. Different thing. Not members. We're being clear about this. 😭)

  • template<typename _T1, typename _T2> constexpr bool operator== (const allocator< _T1 > &, const allocator< _T2 > &) noexcept β€” the cross-type equality check. two allocators, two different template params, one constexpr bool of truth.

πŸ’œ Detailed Description πŸ’œ

template<typename _Tp>
    class __gnu_cxx::allocator< _Tp >
"The standard allocator, as per C++03 [20.4.1].

That's the description. That's the whole description. The class is literally just "the standard allocator, as per C++03 [20.4.1]." Iconic, honestly. No notes. πŸ’€

For further details, the docs point you here, and you should go look because it's actually useful:

https://gcc.gnu.org/onlinedocs/libstdc++/manual/memory.html#std.util.memory.allocator

⭐ Template Parameters ⭐

  • _Tp β€” Type of allocated object. That's what you're allocating, bestie. That's the whole deal.

πŸ‘‘ Author πŸ‘‘

Generated automatically by Doxygen for libstdc++ from the source code. Not a human, not a bestie, just Doxygen doing its little thing. πŸ€–βœ¨


and that's the page, fr fr! 🌸 this one came from the libstdc++ manual β€” it's __gnu_cxx:...ator< _Tp >(3), dated the same as the libstdc++ docs it was generated from, and it's the C++03 standard allocator, no cap. go allocate something, bestie πŸ¦‹πŸ’–

πŸ“¦ 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