__GNU_CXX::MALLOC_ALLOCATOR(3cxx)
π NAME π
__gnu_cxx::malloc_allocator< _Tp > β an allocator that uses malloc. bestie. that's literally it. that's the whole vibe.
(this page lives in section 3cxx of the manual, iykyk π
)
β¨ SYNOPSIS β¨
#include <malloc_allocator.h>
πΈ Public Types πΈ
typedef std::ptrdiff_t difference_typeβ the type you use for distances between pointers, standard-issue πtypedef std::true_type propagate_on_container_move_assignmentβ yes, this container does propagate on container move assignment, her littletrue_typesaid so πtypedef std::size_t size_typeβ the type for sizes and counts, classictypedef _Tp value_typeβ the thing being allocated is_Tp, main character energy π
π¦ Public Member Functions π¦
constexpr malloc_allocator (const malloc_allocator &) noexceptβ copy constructor,constexpr,noexcept, zero drama β¨template<typename _Tp1 > constexpr malloc_allocator (const malloc_allocator< _Tp1 > &) noexceptβ the converting copy constructor, so you can build one from an allocator of a different type_Tp1. alsoconstexpr, alsonoexcept. slay_Tp * allocate (size_type __n, const void *=0)β hands you back_Tp *. takes__nand a secondconst void *argument that defaults to0. this is where themallochappens πvoid deallocate (_Tp *__p, size_type)β gives the memory back. takes the pointer__pand a size. this is where thefreehappens π§
π Friends π
template<typename _Up > constexpr bool operator== (const malloc_allocator &, const malloc_allocator< _Up > &) noexceptβ the equality comparison between twomalloc_allocators, and it's templated on_Upso the two sides can be different types.constexpr,noexcept, friendship confirmed π«Ά
β Detailed Description β
template<typename _Tp>
class __gnu_cxx::malloc_allocator< _Tp >
"An allocator that uses malloc." β that's the official tagline, no notes.
This is precisely the allocator defined in the C++ Standard. like, the actual one. no cap.
- π all allocation calls
malloc - π all deallocation calls
free
and that's the entire personality. lowkey iconic, highkey simple.
bestie did you catch that β allocation =malloc, deallocation =free, exactly as the Standard defines. no extra spice, no hidden behaviour, just the two C functions doing their thing.
π Author π
Generated automatically by Doxygen for libstdc++ from the source code. (not me writing it by hand at 3am, the robots did it π)
okay that's the whole page, mwah π β this cutie was generated automatically by Doxygen for libstdc++ from the source code, and it's serving __gnu_cxx::malloc_allocator< _Tp > from the 3cxx section of the manual. go forth and allocate responsibly β¨ππ¦
π¦ where this page comes from
- debian trixie: libstdc++-12-doc 12.4.0-5
- debian trixie: libstdc++-13-doc 13.3.0-16
- ubuntu noble: libstdc++-12-doc 12.3.0-17ubuntu1
- ubuntu noble: libstdc++-12-doc 12.4.0-2ubuntu1~24.04.1
- ubuntu noble: libstdc++-13-doc 13.2.0-23ubuntu4
- ubuntu noble: libstdc++-13-doc 13.3.0-6ubuntu2~24.04.1
- ubuntu noble: libstdc++-14-doc 14-20240412-0ubuntu1
- ubuntu questing: libstdc++-12-doc 12.5.0-6ubuntu1
- ubuntu questing: libstdc++-13-doc 13.4.0-4ubuntu1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms