C++ 17에서 weak_from_this() 항목이 추가되었다.
예제) s
class Foo : public enable_shared_from_this<Foo>
{
public:
shared_ptr<Foo> getPointer()
{
return shared_from_this();
}
weak_ptr<Foo> GetWeakPointer()
{
return weak_from_this();
}
};
int main()
{
auto ptr1 = make_shared();
auto ptr2 = ptr1->getPointer();
}
'C++ > C++ 11 14 17' 카테고리의 다른 글
Uniform Intialzation. - 사용예제 (0) | 2019.06.25 |
---|---|
C++17, structure binding, if(init; condition) switch(init;condition) (0) | 2018.04.18 |
C++ 11 ENUM (0) | 2018.04.11 |
auto keyword (0) | 2018.04.05 |
Aggregate and POD (0) | 2018.04.04 |