std::pmr::p...::deallocate(3)

πŸ“¦ version 2024.07.05, in nixpkgs unstable, opensuse-leap 16.0

πŸ’– NAME πŸ’–

okay so we're looking at std::pmr::p...::deallocate(3) β€” aka std::pmr::polymorphic_allocator::deallocate β€” from the C++ Standard Libary manual (yes, that spelling is literally in the header 😭). It's the deallocation girlie of the polymorphic_allocator family, and she is here to say bye to memory the right way πŸ’….

✨ Synopsis ✨

The signature is giving very concise, very C++17-core:

void deallocate( T* p, std::size_t n );

(since C++17) β€” periodt, we love a modern king πŸ‘‘.

🌸 DESCRIPTION 🌸

So bestie, deallocate deallocates the storage pointed to by p 🫢. But plot twist: p must have been allocated from a std::pmr::memory_resource x that compares equal to *resource() using x.allocate(n * sizeof(T), alignof(T)). no cap, that's the whole vibe check for p πŸ”₯.

It's equivalent to this exact little line of business:

this->resource()->deallocate(p, n * sizeof(T), alignof(T));

highkey just forwarding the whole thing to the resource and letting it handle the actual deallocation energy 🧚✨.

πŸŽ€ PARAMETERS πŸŽ€

  • p β€” pointer to memory to deallocate 🫢
  • n β€” the number of objects originally allocated πŸ’–

πŸ’€ EXCEPTIONS πŸ’€

Throws nothing. not a single thing. zero drama, zero chaos, absolutely iconic 😌✨.

πŸ¦‹ SEE ALSO πŸ¦‹

  • deallocate_bytes β€” free raw memory obtained from allocate_bytes (C++20) (public member function)
  • deallocate_object β€” frees raw memory obtained by allocate_object (C++20) (public member function)
  • delete_object β€” destroys and deallocates an object (C++20) (public member function)
  • deallocate [static] β€” deallocates storage using the allocator (public static member function of std::allocator_traits<Alloc>)
  • deallocate β€” deallocates memory (public member function of std::pmr::memory_resource)

mwah πŸ’‹ β€” source/version: http://cppreference.com, dated 2024.06.10. that's the whole page, bestie, go forth and deallocate responsibly πŸ«ΆπŸŒˆπŸ’œ

πŸ“¦ where this page comes from