STD::ALLOCATOR(3)
β¨ NAME β¨
std::allocator< _Tp > β the standard allocator, exactly as C++03 says it should be, straight outta [20.4.1]. π
This is your <memory> era, bestie β the whole page lives in the libstdc++ manual (that's the Library Functions Manual, section 3, so it's a library call, not a command, iykyk).
πΈ SYNOPSIS πΈ
#include <memory>
And okay, this one inherits std::__new_allocator< _Tp >. So like, the parent class did a lot of the heavy lifting and std::allocator is out here being the glow-up. π
π Public Types π
typedef ptrdiff_t difference_typeβ the type it uses when it's talking about differences between things (signed, obviously, 'cause differences go both ways).using propagate_on_container_move_assignmentβ yes bestie, this alias exists. It's part of the whole "does the allocator tag along when the container gets move-assigned" situation.typedef size_t size_typeβ how it measures sizes. Unsigned, standard issue.typedef _Tp value_typeβ the type of the thing you're actually allocating. That's literally what_Tpis here for. π
π¦ Public Member Functions π¦
constexpr allocator (const allocator &__a) noexceptβ copy constructor. Copies another allocator, and it'snoexcept, so it will not be dramatic about it.template<typename _Tp1> constexpr allocator (const allocator< _Tp1 > &) noexceptβ the conversion constructor. Yes, you can build one of these from an allocator of a different_Tp1.noexceptagain. Very chill. πconstexpr _Tp * allocate (size_type __n, const void *=static_cast< const void * >(0))β the allocate that takes a size and an optional hint pointer, which defaults tostatic_cast<const void *>(0). Gives you back a_Tp *.constexpr _Tp * allocate (size_t __n)β the simple allocate. Just give it__nand it hands you a_Tp *. That's it, that's the vibe.constexpr allocation_result< _Tp *, size_t > allocate_at_least (size_t __n)β allocate at least__n, and get back anallocation_result< _Tp *, size_t >so you know what you actually got. Overachieving, but make it constexpr. β¨constexpr void deallocate (_Tp *__p, size_t __n)β give back what you took: the pointer__pand the size__n. Cleanup era. π§Ήallocator & operator= (const allocator &)=defaultβ the copy assignment, defaulted. Nothing custom, nothing weird, just the compiler's finest work.
π Friends π
constexpr bool operator== (const allocator &, const allocator &) noexceptβ friend of the class, compares two allocators, returns abool, and it'snoexcept. Equality rights. π«Ά
π Related Symbols π
Heads up: these are not member symbols. They just live nearby.
template<typename _T1, typename _T2> constexpr bool operator== (const allocator< _T1 > &, const allocator< _T2 > &) noexceptβ the cross-type comparison. Two allocators with different template params can still be compared for equality, and yes, it'sconstexprandnoexcept. Iconic, honestly.
β Detailed Description β
template<typename _Tp>
class std::allocator< _Tp >
"The standard allocator, as per C++03 [20.4.1]."
That's the whole description. Short, sweet, main character energy. π
Want the further details? The docs point you here:
https://gcc.gnu.org/onlinedocs/libstdc++/manual/memory.html#std.util.memory.allocator
π Template Parameters π
_Tpβ type of allocated object. That's the one. That's the whole parameter. π
π Author π
Generated automatically by Doxygen for libstdc++ from the source code. So like, a robot wrote this and I'm just here giving it the personality transplant it deserved. π€β¨
Okay bestie, that's the whole page β this is libstdc++, std::allocator< _Tp >(3), and that's a wrap fr fr. Go forth and allocate responsibly, and remember: whatever you allocate, you deallocate. No leaks in this group chat. πππ¦π
π¦ 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