STD::ENABLE_SHARED_FROM_THIS(3cxx)

πŸŽ€ NAME πŸŽ€

okay so welcome to the 3cxx manual page for std::enable_sh...rom_this< _Tp >β€”the header repeats that truncated title, and the manual name is 3cxx, so we’re folding it in right here, bestie. The full class name is std::enable_shared_from_this< _Tp >.

  • std::enable_shared_from_this< _Tp > β€” Base class allowing use of the member function shared_from_this.

✨ SYNOPSIS ✨

#include <memory>

Here’s the whole cast, no cap:

πŸ’– Public Member Functions πŸ’–

shared_ptr< _Tp > shared_from_this ()
shared_ptr< const _Tp > shared_from_this () const

    weak_ptr< _Tp > weak_from_this () noexcept
    weak_ptr< const _Tp > weak_from_this () const noexcept

πŸ›‘οΈ Protected Member Functions πŸ›‘οΈ

enable_shared_from_this (const enable_shared_from_this &) noexcept
enable_shared_from_this & operator= (const enable_shared_from_this &)
    noexcept

🫢 Friends 🫢

the friend zone, literally:

const enable_shared_from_this * __enable_shared_from_this_base (const
       __shared_count<> &, const enable_shared_from_this *__p)
template<typename , _Lock_policy > class __shared_ptr

πŸ¦‹ Detailed Description πŸ¦‹

This is the class template vibe in all its glory:

template<typename _Tp>
    class std::enable_shared_from_this< _Tp >"Base class allowing use of the
    member function shared_from_this.

Since: C++11

so yeah, it’s the base class that lets you use the member function shared_from_thisβ€”iconic since C++11. πŸ’…


πŸ”₯ Member Function Documentation πŸ”₯

Two weak_from_this() flavors, both inline, both noexcept, both since C++17β€”periodt.

πŸ§šβ€β™€οΈ weak_from_this() const πŸ§šβ€β™€οΈ

template<typename _Tp > weak_ptr< const _Tp > std::enable_shared_from_this<
       _Tp >::weak_from_this () const [inline],  [noexcept]

Get a weak_ptr referring to the object that has *this as its base.

Since: C++17

πŸ§šβ€β™€οΈ weak_from_this() πŸ§šβ€β™€οΈ

template<typename _Tp > weak_ptr< _Tp > std::enable_shared_from_this< _Tp
       >::weak_from_this () [inline],  [noexcept]

Get a weak_ptr referring to the object that has *this as its base.

Since: C++17


πŸ’Œ Author πŸ’Œ

Generated automatically by Doxygen for libstdc++ from the source code.

blame the robots, lovingly. 🫢


okay final sign-off bestie: the footer’s source/version situash is the libstd + 3cxx version of this page (the one with the truncated std::enable_sh...rom_this< _Tp > title), and there’s no date shown in the footerβ€”so we’re keeping it dateless, no cap. bye πŸ’…βœ¨

πŸ“¦ where this page comes from