std::pmr::p...c_allocator(3)
π NAME π
okay bestie, this page is all about std::pmr::polymorphic_allocator::polymorphic_allocator β yes, thatβs the same name twice, because itβs the constructor page for std::pmr::polymorphic_allocator. It lives in the C++ Standard Libary manual (and yes, thatβs how the manual name is spelled β Iβm not fixing it, Iβm just reporting the vibes π).
πΈ Synopsis πΈ
Hereβs the whole constructor squad, laid out exactly like the page does it:
polymorphic_allocator() noexcept;
(1)
polymorphic_allocator( const polymorphic_allocator& other ) = default; (2)
template< class U >
(3)
polymorphic_allocator( const polymorphic_allocator<U>& other ) noexcept;
polymorphic_allocator( std::pmr::memory_resource* r );
(4)
Constructs a new polymorphic_allocator. Thatβs the main character job, periodt π
(1)β Constructs apolymorphic_allocatorusing the return value ofstd::pmr::get_default_resource()as the underlying memory resource.(2),(3)β Constructs apolymorphic_allocatorusingother.resource()as the underlying memory resource.(4)β Constructs apolymorphic_allocatorusingras the underlying memory resource. This constructor provides an implicit conversion fromstd::pmr::memory_resource*.
π Parameters π
otherβ anotherpolymorphic_allocatorto copy from. πrβ pointer to the memory resource to use. May not be null. fr fr do not pass null π₯
π Exceptions π
(4)β Throws nothing. Iconic. No drama, no chaos, just quiet slay.
π§ Notes π§
Copying a container using a polymorphic_allocator will not call the allocatorβs copy constructor. Nope, thatβs not the move.
Instead, the new container will use the return value of select_on_container_copy_construction (a default-constructed polymorphic_allocator) as its allocator. Thatβs the lowkey important plot twist π
π See also π
select_on_container_copy_constructionβ create a newpolymorphic_allocatorfor use by a containerβs copy constructor (public member function). π«Ά
mwah π source: http://cppreference.com Β· version/date: 2024.06.10 Β· page title: std::pmr::p...c_allocator(3)
π¦ where this page comes from
- nixpkgs unstable: stdman 2024.07.05
- opensuse-leap 16.0: stdman 2024.07.05-bp160.1.9 Β· MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms