std::enable_shared_from_this::weak_from_this

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

返回 std::weak_ptr<T> ,跟踪所有既存的指代 *thisstd::shared_ptr 所拥有的 *this 的所有权。

目录

注意

这是作为 enabled_shared_from_this 一部分的私有 mutable weak_ptr 成员的副本。

返回值

与既存的 std::shared_ptr 共享 *this 所有权的 std::weak_ptr<T>

示例

参阅

(C++11)
拥有共享对象所有权语义的智能指针
(类模板)

版本历史

  • (当前 | 先前 2017年9月9日 (六) 08:13Fruderica讨论 | 贡献 . . (823字节) (-3). . (撤销)
  • 当前 | 先前) 2017年9月9日 (六) 08:12Fruderica讨论 | 贡献. . (826字节) (+826). . (以“{{cpp/memory/enable_shared_from_this/title | weak_from_this}} {{cpp/memory/enable_shared_from_this/navbar}} {{dcl begin}} {{dcl | since=c++17| num=1 | 1= std::weak_...”为内容创建页面)