enable_shared_from_this 클래스
shared_ptr을 생성할 수 있습니다.
template<class Ty>
class enable_shared_from_this {
public:
shared_ptr<Ty> shared_from_this();
shared_ptr<const Ty> shared_from_this() const;
protected:
enable_shared_from_this();
enable_shared_from_this(const enable_shared_from_this&);
enable_shared_from_this& operator=(const enable_shared_from_this&);
~enable_shared_from_this();
};
매개 변수
- Ty
공유 포인터에 제어되는 형식입니다.
설명
The template class can be used as a public base class to simplify creating shared_ptr 클래스 objects that own objects of the derived type:
class derived
: public enable_shared_from_this<derived>
{
};
shared_ptr<derived> sp0(new derived);
shared_ptr<derived> sp1 = sp0->shared_from_this();
The constructors, destructor, and assignment operator are protected to help prevent accidental misuse. The template argument type Ty must be the type of the derived class.
요구 사항
헤더 <memory>
네임스페이스: std