Sdílet prostřednictvím


weak_ptr::use_count

Spočítá počet určený shared_ptr objektů.

long use_count() const;

Poznámky

Vrátí počet členské funkce shared_ptr objekty, které vlastní zdroje odkazuje *this.

Příklad

 

// std_tr1__memory__weak_ptr_use_count.cpp 
// compile with: /EHsc 
#include <memory> 
#include <iostream> 
 
int main() 
    { 
    std::shared_ptr<int> sp1(new int(5)); 
    std::weak_ptr<int> wp(sp1); 
    std::cout << "wp.use_count() == " 
        << wp.use_count() << std::endl; 
 
    std::shared_ptr<int> sp2(sp1); 
    std::cout << "wp.use_count() == " 
        << wp.use_count() << std::endl; 
 
    return (0); 
    } 
 
  

Požadavky

Záhlaví: <memory>

Obor názvů: std

Viz také

Referenční dokumentace

weak_ptr Class