下面我们写一个小程序来测试下自己实现的unique_ptr,代码如下: #include <iostream> #include "unique_ptr.cpp" class Widget{ public: Widget(){ std::cout << "Widget::constructor" << std::endl; } ~Widget(){ std::cout << "Widget::destructor" << std::endl; } void fun(){ std::cout <...
unique_ptr(constunique_ptr&)=delete;unique_ptr&operator=(constunique_ptr&)=delete;private:std::pair<D,pointer>_Mypair;};structPerson{Person()=default;~Person(){std::cout<<"destructor"<<std::endl;}};intmain(){autodelF=[](autoptr){deleteptr;std::cout<<"delete function"<<std::endl;}...