Namespaces
Variants

deduction guides for std::weak_ptr

From cppreference.net
Memory management library
( exposition only* )
Allocators
Uninitialized memory algorithms
Constrained uninitialized memory algorithms
Memory resources
Uninitialized storage (until C++20)
( until C++20* )
( until C++20* )
( until C++20* )

Garbage collector support (until C++23)
(C++11) (until C++23)
(C++11) (until C++23)
(C++11) (until C++23)
(C++11) (until C++23)
(C++11) (until C++23)
(C++11) (until C++23)
헤더에 정의됨 <memory>
template < class T >
weak_ptr ( std:: shared_ptr < T > ) - > weak_ptr < T > ;
(C++17부터)

하나의 deduction guide std::weak_ptr 에 대해 제공되며, 이는 암시적 deduction guide에서 누락된 특수한 경우를 처리하기 위함입니다.

예제

#include <memory>
int main()
{
    auto p = std::make_shared<int>(42);
    std::weak_ptr w{p}; // 이 경우 명시적 deduction guide가 사용됨
}