Windows apps
Collapse the table of content
Expand the table of content
Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

weak_ptr::reset

 

Releases owned resource.

void reset();

The member function releases the resource pointed to by *this and converts *this to an empty weak_ptr object.

Example

 

// 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); 
    } 

*wp.lock() == 5
wp.expired() == false
wp.expired() == true

Requirements

Header: <memory>

Namespace: std

Show:
© 2017 Microsoft