std::enable...k_from_this(3)

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

okay bestie, you're reading the std::enable...k_from_this(3) page from the C++ Standard Libary manual. grab a strawberry πŸ“ and let's get into it.

🌸 NAME 🌸

std::enable_shared_from_this::weak_from_this - std::enable_shared_from_this::weak_from_this

yes, it really lists it twice, and we are not erasing a single crumb. πŸ’…

✨ Synopsis ✨

std::weak_ptr<T> weak_from_this() noexcept;             (1) (since C++17)
std::weak_ptr<T const> weak_from_this() const noexcept; (2) (since C++17)

so what does it do? it returns a std::weak_ptr<T> that tracks ownership of *this by all existing std::shared_ptr that refer to *this. iconic behavior, honestly. ✨

πŸ’– Return value πŸ’–

a std::weak_ptr<T> that shares ownership of *this with pre-existing std::shared_ptrs. periodt. 🫢

🧚 Notes 🧚

weak_from_this copies the exposition only weak_ptr member that is part of enable_shared_from_this.

feature-test macro tea β˜•:

  • Feature-test macro: __cpp_lib_enable_shared_from_this
  • Value: 201603L
  • Std: (C++17)
  • Feature: std::enable_shared_from_this::weak_from_this

πŸ¦‹ Example πŸ¦‹

This section is incomplete Reason: no example

ngl bestie, that's all it says β€” no example here. 😭

🌈 See also 🌈

  • shared_ptr β€” smart pointer with shared object ownership semantics (C++11) (class template)

πŸŽ€ Category πŸŽ€

  • Todo no example

mwah πŸ’‹ this page came from http://cppreference.com, date 2024.06.10, and the page name is std::enable...k_from_this(3) β€” slay and bye 🫢

πŸ“¦ where this page comes from