std::weak_ptr
的推导指引
来自 cppreference.cn
定义于头文件 <memory> |
||
template< class T > weak_ptr( std::shared_ptr<T> ) -> weak_ptr<T>; |
(自 C++17 起) | |
为 std::weak_ptr 提供了一个推导指引,以处理隐式推导指引遗漏的边缘情况。
[编辑] 示例
运行此代码
#include <memory> int main() { auto p = std::make_shared<int>(42); std::weak_ptr w{p}; // explicit deduction guide is used in this case }