다음을 통해 공유


shared_ptr::use_count

리소스 소유자의 수를 계산합니다.

long use_count() const;

설명

The member function returns the number of shared_ptr objects that own the resource that is owned by *this.

예제

 

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

요구 사항

헤더 <memory>

네임스페이스: std

참고 항목

참조

shared_ptr 클래스