1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
|
// weak_ptr::reset example
#include <iostream>
#include <memory>
int main () {
std::shared_ptr<int> sp (new int(10));
std::weak_ptr<int> wp(sp);
std::cout << "1. wp " << (wp.expired()?"is":"is not") << " expired\n";
wp.reset();
std::cout << "2. wp " << (wp.expired()?"is":"is not") << " expired\n";
return 0;
}
|