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 _Tp is here for. πŸ‘‘

πŸ¦‹ Public Member Functions πŸ¦‹

  • constexpr allocator (const allocator &__a) noexcept β€” copy constructor. Copies another allocator, and it's noexcept, 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. noexcept again. 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 to static_cast<const void *>(0). Gives you back a _Tp *.
  • constexpr _Tp * allocate (size_t __n) β€” the simple allocate. Just give it __n and 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 an allocation_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 __p and 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 a bool, and it's noexcept. Equality rights. 🫢

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's constexpr and noexcept. 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