【发布时间】:2015-11-09 11:26:17
【问题描述】:
我有以下代码,第 2 行在编译期间给了我一个错误。是否可以创建范围指针映射,还是必须使用共享指针?
map<int, scoped_ptr> mp;
mp[1] = scoped_ptr(new obj());
错误:
boost::scoped_ptr<T>& boost::scoped_ptr<T>::operator=(const boost::scoped_ptr<T>&) [with T = ]’ is private
【问题讨论】:
-
boost::scoped_ptr或std::unique_ptr? C++11 ? -
如果你无法访问 c++11,请使用 boost::ptr_container。它可以满足您的需求。
标签: c++ dictionary scoped-ptr