각종 지침
1277 단어 지능형 포인터 제품군총결산
1. scoped_refptr
사용법:scopedrefptr는 명시적으로만 참조 메타데이터 인터페이스의 유형을 구현할 수 있습니다.
template
class scoped_refptr {
public:
scoped_refptr(T* p) : ptr_(p) {
if (ptr_)
ptr_->AddRef();
}
~scoped_refptr() {
if (ptr_)
ptr_->Release();
}
protected:
T* ptr_;
};
Public base:::RefCountedThreadSafe를 상속해야 하는 이유인용 계수 관리를 돕기 위해:
template >
class RefCountedThreadSafe : public subtle::RefCountedThreadSafeBase {
public:
void AddRef() {
subtle::RefCountedThreadSafeBase::AddRef();
}
void Release() {
if (subtle::RefCountedThreadSafeBase::Release()) {
Traits::Destruct(static_cast(this));
}
}
};
void RefCountedThreadSafeBase::AddRef() {
AtomicRefCountInc(&ref_count_);
}
2. std::unique_ptr
단일 소유권의 대상.std::unique 사용ptr.주의해야 할 것은, std::uniqueptr가 가지고 있는 수요는 반드시 인용 계수가 아닌 것이며, 무더기에 분배된 대상이어야 한다.
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
Mybatis 학습 요약의 mybatis 사용 제안
주석이나 문서가 양호하지 않으면 모든 층의 코드를 잘 알아야 어떤 매개 변수를 전달했는지 알 수 있습니다.간단한 MVC에 대해서도 괜찮지만, 만약 차원이 복잡한 후에 코드가 매우 복잡해지고, 만약 내가 매개 변수를 ...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
Mybatis 학습 요약의 mybatis 사용 제안주석이나 문서가 양호하지 않으면 모든 층의 코드를 잘 알아야 어떤 매개 변수를 전달했는지 알 수 있습니다.간단한 MVC에 대해서도 괜찮지만, 만약 차원이 복잡한 후에 코드가 매우 복잡해지고, 만약 내가 매개 변수를 ...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.