weak_ptr::reset

释放的资源。

void reset();

备注

成员函数释放资源由 *this 指向和转换 *this 为空 weak_ptr 对象。

示例

 

// std_tr1__memory__weak_ptr_reset.cpp 
// compile with: /EHsc 
#include <memory> 
#include <iostream> 
 
int main() 
    { 
    std::shared_ptr<int> sp(new int(5)); 
    std::weak_ptr<int> wp(sp); 
    std::cout << "*wp.lock() == " << *wp.lock() << std::endl; 
    std::cout << "wp.expired() == " << std::boolalpha 
        << wp.expired() << std::endl; 
 
    wp.reset(); 
    std::cout << "wp.expired() == " << std::boolalpha 
        << wp.expired() << std::endl; 
 
    return (0); 
    } 
 
  

要求

页眉: <内存>

命名空间: std

请参见

参考

weak_ptr 类

weak_ptr::operator=