C++ 语言/间接/智能指针/智能编译器临时变量
外观
C++ 为 std::unique_ptr<CRComplex> piVar(new CRComplex(11,22)); 中的 new CRComplex(11,22) 部分创建了一个编译器临时变量。为了防止在该编译器临时变量传递给智能指针之前出现异常导致内存泄漏,请使用 std::make_unique<CRComplex>(11,22) 代替 new CRComplex(11,22)(std::make_unique<>() 编译器临时变量在创建时就已经是智能指针了)。