Partager via


weak_ptr::element_type

The type of the element.

typedef Ty element_type;

Remarks

The type is a synonym for the template parameter Ty.

Example

 

// std_tr1__memory__weak_ptr_element_type.cpp 
// compile with: /EHsc 
#include <memory> 
#include <iostream> 
 
int main() 
    { 
    std::shared_ptr<int> sp0(new int(5)); 
    std::weak_ptr<int> wp0(sp0); 
    std::weak_ptr<int>::element_type val = *wp0.lock(); 
 
    std::cout << "*wp0.lock() == " << val << std::endl; 
 
    return (0); 
    } 
 
*wp0.lock() == 5

Requirements

Header: <memory>

Namespace: std

See Also

Reference

weak_ptr Class