STD::DEFAULT_DELETE(3)

πŸ‘‘ std::default_delete< _Tp > β€” Library Functions Manual πŸ’…

okay bestie, sit down, we're doing C++ memory management today and honestly? it's giving cleanup era. this little icon lives in the Library Functions Manual (libstdc++ girlies rise), and it's the thing that goes "and then we delete it" when your unique_ptr is done being the main character.


✨ NAME ✨

std::default_delete< _Tp > β€” no cap, that's the whole name, she's simple and she knows it πŸ’–


πŸŽ€ SYNOPSIS πŸŽ€

#include <memory>

🌸 Public Member Functions

  • constexpr default_delete () noexcept=default β€” the default constructor, literally just vibing, does nothing, iconic ✨
  • template<typename _Up, typename = _Require<is_convertible<_Up*, _Tp*>>> constexpr default_delete (const default_delete< _Up > &) noexcept β€” the converting constructor, she lets other deleters in conditionally (iykyk, more on that below πŸ¦‹)
  • constexpr void operator() (_Tp *__ptr) const β€” the moment we've all been waiting for: it calls delete __ptr. periodt πŸ’€

πŸ’œ Detailed Description

template<typename _Tp>
struct std::default_delete< _Tp >

so this is the primary template of default_delete, and her whole job description is: used by unique_ptr for single objects. not arrays. single objects. we're monogamous here 🫢

Since: C++11 ⭐ (she's been on the scene for a minute and she ate)


🧚 Constructor & Destructor Documentation

🌈 template<typename _Tp> std::default_delete< _Tp >::default_delete ()

[constexpr], [default], [noexcept]

Default constructor. that's it, that's the girl. she constructs and she defaults and she does it without throwing anything at you 😌

Fun lil note from the docs: Referenced by default_delete(). yes she references herself, it's called self-love, look it up πŸ’…

πŸ¦‹ template<typename _Tp> template<typename _Up, typename = _Require<is_convertible<_Up*, _Tp*>>> std::default_delete< _Tp >::default_delete (const default_delete< _Up > & )

[inline], [constexpr], [noexcept]

Converting constructor. this one is the social butterfly πŸ¦‹ β€” it lets you convert from a deleter meant for objects of a whole other type, _Up, but only if _Up* is convertible to _Tp*. if that conversion doesn't hold up? she's not letting you in. gatekeeping, but make it type-safe ✨

References default_delete().


πŸ”₯ Member Function Documentation

⭐ template<typename _Tp> void std::default_delete< _Tp >::operator() (_Tp * __ptr) const

[inline], [constexpr]

Calls delete __ptr. that's the entire plot of this function, no subplot, no side quest, we love a one-line queen πŸ‘‘


🌟 Author 🌟

Generated automatically by Doxygen for libstdc++ from the source code. (not a human author bestie, the machines did this one πŸ€–)


⚠️ real talk, no jokes: this is the default deleter and it does exactly what it says β€” delete __ptr. the whole design is that unique_ptr owns a single object and this is what gets called when ownership ends. don't get cute with it.

and that's the whole page!! πŸŽ€ mwah πŸ’– sending you off with the official sign-off: this came from the libstdc++ corner of the world, filed under that iconic truncated header std::defau...ete< _Tp >(3) β€” yes the man page literally shortens its own name, she's mysterious like that πŸ’€βœ¨ byeee, go free your pointers responsibly 🫢🌸

πŸ“¦ where this page comes from
  • arch rolling: gcc 16.2.1+r23+gd564253eb6c8-1 Β· GPL-3.0-or-later WITH GCC-exception-3.1 AND GFDL-1.3-or-later
  • fedora 44: libstdc++-docs 16.0.1-0.10.fc44 Β· GPL-3.0-or-later AND LGPL-3.0-or-later AND (GPL-3.0-or-later WITH GCC-exception-3.1) AND (GPL-3.0-or-later WITH Texinfo-exception) AND (LGPL-2.1-or-later WITH GCC-exception-2.0) AND (GPL-2.0-or-later WITH GCC-exception-2.0) AND (GPL-2.0-or-later WITH GNU-compiler-exception) AND BSL-1.0 AND GFDL-1.3-or-later AND Linux-man-pages-copyleft-2-para AND SunPro AND BSD-1-Clause AND BSD-2-Clause AND BSD-2-Clause-Views AND BSD-3-Clause AND BSD-4-Clause AND BSD-Source-Code AND Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 WITH LLVM-Exception) AND ZPL-2.1 AND ISC AND LicenseRef-Fedora-Public-Domain AND HP-1986 AND curl AND Martin-Birgmeier AND HPND-Markus-Kuhn AND dtoa AND SMLNJ AND AMD-newlib AND OAR AND HPND-merchantability-variant AND HPND-Intel
  • fedora 44: libstdc++-docs 16.2.1-2.fc44
  • fedora 44: libstdc++-docs 16.2.1-3.fc44 Β· GPL-3.0-or-later AND LGPL-3.0-or-later AND (GPL-3.0-or-later WITH GCC-exception-3.1) AND (GPL-3.0-or-later WITH Texinfo-exception) AND (LGPL-2.1-or-later WITH GCC-exception-2.0) AND (GPL-2.0-or-later WITH GCC-exception-2.0) AND (GPL-2.0-or-later WITH GNU-compiler-exception) AND BSL-1.0 AND GFDL-1.3-or-later AND Linux-man-pages-copyleft-2-para AND SunPro AND BSD-1-Clause AND BSD-2-Clause AND BSD-2-Clause-Views AND BSD-3-Clause AND BSD-4-Clause AND BSD-Source-Code AND Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 WITH LLVM-Exception) AND ZPL-2.1 AND ISC AND LicenseRef-Fedora-Public-Domain AND HP-1986 AND curl AND Martin-Birgmeier AND HPND-Markus-Kuhn AND dtoa AND SMLNJ AND AMD-newlib AND OAR AND HPND-merchantability-variant AND HPND-Intel
  • πŸ’– girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms