std::alloca...ts::destroy(3)

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

πŸ’– NAME πŸ’–

std::allocator_traits::destroy - std::allocator_traits::destroy. Yes bestie, the NAME line is literally that twice, it’s giving β€œsay it back” energy 😭. This page lives in the C++ Standard Libary manual (that’s the manual name, typo and all, we’re not fixing the header πŸ’…). The header up top says std::alloca...ts::destroy(3), truncated like that, no cap.

✨ Synopsis ✨

Defined in header <memory>
template< class T >                               (since C++11)
static void destroy( Alloc& a, T* p );            (until C++20)
template< class T >                               (since C++20)
static constexpr void destroy( Alloc& a, T* p );

This function calls the destructor of the object pointed to by p. If possible, it does so by calling a.destroy(p). If that’s not possible (e.g. Alloc does not have the member function destroy()), then it calls the destructor of *p directly, as p->~T() (until C++20), or std::destroy_at(p) (since C++20). Fallback queen behavior, honestly πŸ‘‘.

πŸŽ€ Parameters πŸŽ€

  • a β€” allocator to use for destruction
  • p β€” pointer to the object being destroyed

🌈 Return value 🌈

(none) β€” she gives nothing back, and that’s iconic. No return value, no drama ✨.

πŸ¦‹ Notes πŸ¦‹

Because this function provides the automatic fall back to direct call to the destructor, the member function destroy() is an optional Allocator requirement since C++11. So yeah, destroy() is optional, and the fallback has your back πŸ’–.

πŸ“ Example πŸ“

This section is incomplete.

Reason: no example.

No example bestie, it literally says so 😭. We move.

πŸ‘‘ See also πŸ‘‘

  • destroy β€” destructs an object in allocated storage (until C++20) (public member function of std::allocator<T>)

πŸ’€ Category πŸ’€

  • * Todo no example β€” that’s the category tag, fr fr. No-example energy confirmed 🫠.

okay bestie that’s the whole page πŸ’– cute sign-off time: this came from http://cppreference.com, version/date 2024.06.10, and the footer title is std::alloca...ts::destroy(3). byeee, go destroy some objects responsibly 🫢✨

πŸ“¦ where this page comes from