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);
}
需求
標頭: <memory>
命名空間: std