STD::PMR_POLYMORPHIC_ALLOCATOR(3)

πŸ“¦
version 16.2.1+r23+gd564253eb6c8 Β· 5 versions
, in arch rolling, fedora 44

πŸ’– NAME πŸ’–

std::pmr::polymorphic_allocator< _Tp > β€” bestie it's a Class template called polymorphic_allocator. That's the whole vibe. It's a template, it's polymorphic, it allocates, slay. ✨

(also hi, you're reading the Library Functions Manual page for it, section 3, we love a numbered-section moment 🫢)


✨ SYNOPSIS ✨

First things first, you gotta pull it in:

#include <memory_resource>

That's it. That's the include. No cap. πŸ¦‹

πŸŽ€ Public Types πŸŽ€

  • using value_type β€” the public type, just chillin' right there. Yes, that's genuinely all it says. Iconic minimalism. πŸ’…

🌸 Public Member Functions 🌸

okay so here's the whole roster, every single one, no skipping, I promised:

  • polymorphic_allocator (const polymorphic_allocator &__other)=default β€” copy constructor, and it's =default, so the compiler handles it and honestly? good for it.
  • template<typename _Up> polymorphic_allocator (const polymorphic_allocator< _Up > &__x) noexcept β€” converting constructor from a polymorphic_allocator of a different type _Up. noexcept, so it will NOT be the one to betray you.
  • polymorphic_allocator (memory_resource *__r) noexcept β€” build one from a memory_resource *. Also noexcept. We love a constructor that keeps its promises. 🫢
  • _Tp * allocate (size_t __n) β€” gimme __n of them, hands back a _Tp *.
  • template<typename _Tp1, typename... _Args> void construct (_Tp1 *__p, _Args &&... __args) β€” constructs a thing at __p, forwarding literally all the __args (it's a variadic, periodt).
  • void deallocate (_Tp *__p, size_t __n) noexcept β€” give the memory back. noexcept. bye! πŸ‘‹
  • template<typename _Up> void destroy (_Up *__p) β€” destroys the _Up sitting at __p.
  • polymorphic_allocator & operator= (const polymorphic_allocator &)=delete β€” 🚨 DELETED. You cannot assign one to another. It's not a bug, it's a boundary. Respect the boundary bestie, the compiler will absolutely yell at you and it will be correct. πŸ’€
  • memory_resource * resource () const noexcept β€” hands you back the memory_resource *. const, noexcept, a whole green-flag king. πŸ‘‘
  • polymorphic_allocator select_on_container_copy_construction () const noexcept β€” the special little guy that decides what a container does when it gets copied. const and noexcept, obviously, because it's that kind of method. ✨

🌈 Friends 🌈

  • bool operator== (const polymorphic_allocator &__a, const polymorphic_allocator &__b) noexcept β€” equality comparison between two of them, noexcept, sitting here as a friend like the main character who doesn't need to be a member. πŸ’œ

πŸ¦‹ Detailed Description πŸ¦‹

so, template time:

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

and the description is literally just:

Class template polymorphic_allocator.

that's it. that's the tea. short, sweet, self-assured. πŸ“

Since: C++17 β€” so if you're on C++17 or later, this is your moment. If you're not... bestie. 😭


πŸŽ€ Author πŸŽ€

Generated automatically by Doxygen for libstdc++ from the source code. Not a human, not a girlie, just Doxygen doing its little robot thing. It ate, honestly. πŸ€–βœ¨


and that's the page! πŸ’… thanks for reading all the way to the bottom, you're a real one. this was the libstdc++ section 3 manual page for std::pmr::polymorphic_allocator< _Tp >, so go forth and allocate responsibly, mwah πŸ«ΆπŸ’–πŸŒˆ

πŸ“¦ 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.0.1-0.10.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
  • 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