STD::__NEW_ALLOCATOR(3cxx)
hey bestie π this is the std::__new_allocator< _Tp > page, and the manual name is 3cxx β folded in right here so we can get into it. no cap, we're about to make an allocator manual feel like a group chat.
π NAME π
std::__new_allocator< _Tp > β an allocator that uses global new, as per C++03 [20.4.1]. That's the name, that's the vibe, periodt.
β¨ SYNOPSIS β¨
#include <memory>
Inherited by std::allocator< value_type >, __gnu_cxx::new_allocator< _Tp >, and std::allocator< _Tp >.
π Public Types π
typedef std::ptrdiff_t difference_typeβ the difference type, iconic.typedef std::true_type propagate_on_container_move_assignmentβ yes, the whole long name is the type, and it'sstd::true_type.typedef std::size_t size_typeβ size type, we love to see it.typedef _Tp value_typeβ value type is_Tp, simple as that.
πΈ Public Member Functions πΈ
Here's the function squad, with every signature kept exactly:
- copy constructor β
constexpr __new_allocator (const __new_allocator &) noexcept - template constructor β
template<typename _Tp1 > constexpr __new_allocator (const __new_allocator< _Tp1 > &) noexcept allocateβ exact signature:
_Tp * allocate (size_type __n, const void *=static_cast< const void *
>(0))
deallocateβvoid deallocate (_Tp *__p, size_type __n)- copy assignment β
__new_allocator & operator= (const __new_allocator &)=default
π¦ Friends π¦
template<typename _Up > constexpr bool operator== (const __new_allocator &, const __new_allocator< _Up > &) noexceptβ the friend equality operator, keeping it friendly.
π Detailed Description π
The class is:
template<typename _Tp>
class std::__new_allocator< _Tp >
And its quoted description is "An allocator that uses global new, as per C++03 [20.4.1]."
This is precisely the allocator defined in the C++ Standard. Not me guessing β the manual says it. periodt.
Then the bullet points:
- all allocation calls
operator new - all deallocation calls
operator delete
This is the default base-class implementation of std::allocator, and is also the base-class of the __gnu_cxx::new_allocator extension.
You should use eitherstd::allocatoror__gnu_cxx::new_allocatorinstead of using this directly. That's the manual's actual warning, and I'm keeping it loud π .
Template Parameters
_Tpβ Type of allocated object.
π Author π
Generated automatically by Doxygen for libstdc++ from the source code. So no human author to credit here, just Doxygen doing its thing.
okay bye bestie π«Ά the footer says libstdc++, the manual tag is 3cxx, and there's no extra date line in the footer β so that's the whole cute sign-off, mwah πβ¨
π¦ where this page comes from
- ubuntu noble: libstdc++-14-doc 14-20240412-0ubuntu1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms