std::enable_shared_from_this<T>::weak_from_this

来自cppreference.com
 
 
内存管理库
分配器
内存资源
未初始化存储 (C++20 前*)
垃圾收集器支持 (C++23 前)
 
 
std::weak_ptr<T> weak_from_this() noexcept;
(1) (C++17 起)
(C++26 起为 constexpr)
std::weak_ptr<const T> weak_from_this() const noexcept;
(2) (C++17 起)
(C++26 起为 constexpr)

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

返回值

weak_this

注解

功能特性测试 标准 功能特性
__cpp_lib_enable_shared_from_this 201603L (C++17) std::enable_shared_from_this::weak_from_this

示例

参阅

拥有共享对象所有权语义的智能指针
(类模板) [编辑]
Morty Proxy This is a proxified and sanitized view of the page, visit original site.