vector<auto_ptr<int>> vec;
auto_ptr<int> p(new int(14));
vec.push_back(p);
这样编译会出错,error C2558: class 'std::auto_ptr<_Ty>' : no copy constructor available or copy constructor is declared 'explicit'
auto_ptr在赋值、拷贝构造的时候,内部管理的资源的所有权会被转移
auto_ptr<string> pa = new string();
auto_ptr<string> pb = pa;//pa指向NULL,pb获取资源
pa = pb;//pb指向NULL,pa获取资源
stl容器要求内部元素要能满足拷贝语义,因为stl很多算法都会对元素进行拷贝,auto_ptr的拷贝操作与一般意义上的拷贝的含义不同