std::weak_ptr
的推導指引
來自 cppreference.com
定義於標頭檔案 <memory> |
||
template< class T > weak_ptr( std::shared_ptr<T> ) -> weak_ptr<T>; |
(C++17 起) | |
為 std::weak_ptr 提供了一個推導指引,以處理隱式推導指引遺漏的邊緣情況。
[編輯] 示例
執行此程式碼
#include <memory> int main() { auto p = std::make_shared<int>(42); std::weak_ptr w{p}; // explicit deduction guide is used in this case }