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 callsdelete __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 thatunique_ptrowns 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