STD::PMR_POLYMORPHIC_ALLOCATOR(3cxx)

πŸ’… std::pmr::polymorphic_allocator< _Tp > β€” a.k.a. the libstdc++ (3cxx) page

okay so bestie, sit down, we're talking about std::pmr::polymorphic_allocator< _Tp > from the <memory_resource> world πŸ’– this is the class template polymorphic_allocator, and yes it's giving main character energy in the C++17 polymorphism scene.


✨ NAME ✨

std::pmr::polymorphic_allocator< _Tp > β€” Class template polymorphic_allocator. that's it, that's the name, no cap πŸŽ€


πŸ¦‹ SYNOPSIS πŸ¦‹

#include <memory_resource>

🌸 Public Types 🌸

  • using value_type = _Tp β€” the type it allocates, literally the whole personality 🫢

πŸ’œ Public Member Functions πŸ’œ

  • polymorphic_allocator (const polymorphic_allocator &__other)=default β€” copy constructor, defaulted, doing exactly what you'd expect, iconic
  • template<typename _Up > polymorphic_allocator (const polymorphic_allocator< _Up > &__x) noexcept β€” converting constructor from another polymorphic_allocator< _Up >, and it's noexcept so it will not be dramatic about it
  • polymorphic_allocator (memory_resource *__r) noexcept β€” build one from a memory_resource *__r, also noexcept πŸ‘‘
  • _Tp * allocate (size_t __n) β€” gimme __n of _Tp, hands you a _Tp * ✨
  • void * allocate_bytes (size_t __nbytes, size_t __alignment=alignof(max_align_t)) β€” raw bytes mode, __nbytes of them, with __alignment defaulting to alignof(max_align_t)
  • template<typename _Up > _Up * allocate_object (size_t __n=1) β€” allocates _Up objects, __n defaults to 1 (you get one, bestie 🎁)
  • template<typename _Tp1 , typename... _Args> void construct (_Tp1 *__p, _Args &&... __args) β€” constructs at __p with __args..., the classic
  • void deallocate (_Tp *__p, size_t __n) noexcept β€” gives back __n of _Tp at __p, noexcept, no tears
  • void deallocate_bytes (void *__p, size_t __nbytes, size_t __alignment=alignof(max_align_t)) β€” returns raw bytes: pointer __p, __nbytes, __alignment defaulting to alignof(max_align_t)
  • template<typename _Up > void deallocate_object (_Up *__p, size_t __n=1) β€” gives back __n _Up objects at __p, __n defaults to 1
  • template<typename _Up > void delete_object (_Up *__p) β€” destroys and deallocates the _Up at __p in one lil move πŸ’…
  • template<typename _Up > void destroy (_Up *__p) β€” just destroys the _Up at __p, nothing more
  • template<typename _Up , typename... _CtorArgs> _Up * new_object (_CtorArgs &&... __ctor_args) β€” allocates and constructs a _Up from __ctor_args..., a whole combo meal πŸ“
  • polymorphic_allocator & operator= (const polymorphic_allocator &)=delete β€” assignment is deleted. yes bestie, it's gone, you cannot assign, that's not a bug that's the design πŸ™ˆ
  • memory_resource * resource () const noexcept β€” hands you the memory_resource *, noexcept, the source of truth
  • polymorphic_allocator select_on_container_copy_construction () const noexcept β€” the special copy-construction hook, noexcept, returns a polymorphic_allocator

🧚 Friends 🧚

  • bool operator== (const polymorphic_allocator &__a, const polymorphic_allocator &__b) noexcept β€” compares two of these bad boys, noexcept, returns bool 🌈

πŸ”₯ Detailed Description πŸ”₯

template<typename _Tp>
    class std::pmr::polymorphic_allocator< _Tp >

so the actual text is: "Class template polymorphic_allocator." β€” short, sweet, mysterious, we love a low-word-count legend πŸŽ€

Since: C++17 ⭐ (yes, C++17, that's the era, that's the vibe)


🫢 Author 🫢

Generated automatically by Doxygen for libstdc++ from the source code. not a human, just Doxygen doing its lil thing πŸ€–πŸ’–


aaaand that's the page! πŸ¦‹ this gem came to you from libstdc++, the source is the source code itself, and the lovely Doxygen generated it β€” big thank you to the std::pmr::polymorphic_allocator< _Tp >(3cxx) manual page, mwah πŸ’‹ periodt.

πŸ“¦ where this page comes from