STD::__NEW_ALLOCATOR(3)
π NAME π
std::__new_allocator< _Tp > β an allocator that uses global new, as per C++03 [20.4.1]. That's the whole vibe, bestie, it's the blueprint allocator, the OG, the one the standard literally wrote down. π
β¨ SYNOPSIS β¨
#include <memory>
So like, it's lowkey inherited by a whole friend group: std::allocator< _Up >, std::allocator< value_type >, std::allocator< void >, std::allocator< byte >, __gnu_cxx::new_allocator< _Tp >, and std::allocator< _Tp >. They all showed up to the party and this is the base they're standing on. π«Ά
πΈ Public Types πΈ
typedef std::ptrdiff_t difference_typeβ the type that measures distance between pointers, so iconic for pointer math.typedef std::true_type propagate_on_container_move_assignmentβ yes bestie, it propagates on container move assignment, it said so itself.typedef std::size_t size_typeβ the unsigned type for sizes, classic, never misses.typedef _Tp value_typeβ the type of the thing being allocated, obviously. π
π Public Member Functions π
constexpr __new_allocator (const __new_allocator &) noexceptβ copy constructor,noexcept, it does not do drama. π§template<typename _Tp1> constexpr __new_allocator (const __new_allocator< _Tp1 > &) noexceptβ the templated converting copy constructor, alsonoexcept, it will literally accept a cousin allocator like it's family. πconstexpr _Tp * allocate (size_type __n, const void *=static_cast< const void * >(0))β hands you_Tp*for__nobjects, and that second parameter defaults tostatic_cast< const void * >(0). πconstexpr void deallocate (_Tp *__p, size_type __n)β gives the memory back, takes the pointer__pand the count__n, no questions asked. π__new_allocator & operator= (const __new_allocator &)=defaultβ assignment operator, defaulted, because why reinvent the wheel. β¨
π¦ Friends π¦
template<typename _Up> constexpr bool operator== (const __new_allocator &, const __new_allocator< _Up > &) noexceptβ the equality bestie,noexcept, comparing two allocators across_Up. fr fr, it's giving friendship goals. π
π Detailed Description π
template<typename _Tp>
class std::__new_allocator< _Tp >
"An allocator that uses global new, as per C++03 [20.4.1]."
Okay so bestie, listen: this is precisely the allocator defined in the C++ Standard. Not a remix, not a cover, the actual canonical text. Periodt. π
- all allocation calls
operator newπ₯ - all deallocation calls
operator deleteπ
This is the default base-class implementation of std::allocator, and it's also the base-class of the __gnu_cxx::new_allocator extension. π
Not me begging you to use eitherstd::allocatoror__gnu_cxx::new_allocatorinstead of using this directly. Like, please. This one is the behind-the-scenes main character, not the one you date. π
β Template Parameters β
_Tpβ type of allocated object. That's it, that's the parameter, it's the type of the thing you're allocating. Slay. πΈ
π Author π
Generated automatically by Doxygen for libstdc++ from the source code. The robot wrote it, we just gave it the glow-up. π€β¨
That's the whole page, babe β this one lives in the libstdc++ collection, filed under std::__new...ator< _Tp >(3) in the Library Functions Manual, and it's exactly the kind of low-level lore that makes containers work while nobody claps for it. π«Ά Go forth and let std::allocator handle it for you, iykyk. π¦
π¦ 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