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

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

πŸ’– NAME πŸ’–

std::pmr::polymorphic_allocator::deallocate_object β€” std::pmr::polymorphic_allocator::deallocate_object. Yep, the NAME section said it twice and we're keeping both, bestie. This is the std::pmr::p...cate_object(3) page from the C++ Standard Libary manual. 🫢

✨ Synopsis ✨

Okay so it's a template, and it's been a thing since C++20:

template< class U >
void deallocate_object( U* p, std::size_t n = 1 );

It deallocates the storage pointed to by p. Big caveat: p must have been allocated from a std::pmr::memory_resource x that compares equal to *resource(), using x.allocate(n * sizeof(U), alignof(U)) β€” typically through a call to allocate_object<U>(n). The provenance is giving required, no cap. πŸ’…

It's equivalent to deallocate_bytes(p, n * sizeof(U), alignof(U));.

πŸŽ€ Parameters πŸŽ€

  • p β€” pointer to the memory to deallocate.
  • n β€” number of objects of type U the memory was for.

πŸ’€ Exceptions πŸ’€

Throws nothing. Literally zero drama. ✨

πŸ¦‹ Notes πŸ¦‹

This function was introduced for use with the fully-specialized allocator std::pmr::polymorphic_allocator<>, but it may be useful in any specialization. Highkey flexible icon behavior. 🌈

🌸 See also 🌸

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

Later, bestie! 🫢 Source/version: http://cppreference.com; date: 2024.06.10. That was the std::pmr::p...cate_object(3) page β€” mwah! πŸ’–πŸŽ€

πŸ“¦ where this page comes from