std::allocator::destroy(3)

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

πŸ’… std::allocator::destroy (3) β€” C++ Standard Libary πŸ’…

okay bestie, welcome to the destructor corner of the C++ Standard Libary. This page is for std::allocator::destroy, and it’s lowkey iconic in a β€œplease clean up after yourself” way. πŸŽ€


🌸 NAME 🌸

std::allocator::destroy β€” std::allocator::destroy

yep, the name is the name, no notes πŸ’€

✨ Synopsis ✨

The synopsis is literally:

Defined in header <memory>

void destroy( pointer p ); (1) (until C++11)

template< class U >            (since C++11)
void destroy( U* p );      (2) (deprecated in C++17)
                               (removed in C++20)

It calls the destructor of the object pointed to by p. bestie, that’s the whole vibe. 🫢

  1. Calls p->~T().
  2. Calls p->~U().
heads up: overload 2 is deprecated in C++17 and removed in C++20 β€” so if you’re on C++20+, that one is not invited to the function-call party anymore. πŸ’€

πŸŽ€ Parameters πŸŽ€

  • p β€” pointer to the object that is going to be destroyed. it’s giving β€œyou break it, you clean it” energy. 🧚

πŸ’– Return value πŸ’–

(none) β€” no return value, bestie. it just handles the destructor business and dips. πŸ’…

πŸ’€ Defect reports πŸ’€

The following behavior-changing defect reports were applied retroactively to previously published C++ standards.

  • DR: LWG 400
  • Applied to: C++98
  • Behavior as published: p was cast to T*, which is the type of p
  • Correct behavior: removed the redundant cast

slay, a little cleanup for the history books. 🧹✨

πŸ¦‹ See also πŸ¦‹

  • destroy β€” destructs an object stored in the allocated storage [static] (function template)

okay bestie, that’s the whole page β€” source/version: http://cppreference.com, dated 2024.06.10 πŸ’– periodt. 🌈

πŸ“¦ where this page comes from