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's std::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 either std::allocator or __gnu_cxx::new_allocator instead 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