__GNU_CXX::ALLOCATOR(3)
β¨ 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'snoexceptso 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.noexceptagain, obviously.constexpr _Tp * allocate (size_t __n)β hand me__nand I'll hand you back a pointer. simple as.constexpr _Tp * allocate (size_type __n, const void *=static_cast< const void * >(0))β the otherallocate, with a second param that defaults tostatic_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 anallocation_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__pand the size__nback. 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,constexprandnoexcept. bestie behavior.
π Related Symbols π
(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, oneconstexpr boolof 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