使用std::xxx数据结构

220 阅读1分钟
要么存储指针,类似于
std::map<int, std::shared_ptr<Task>> map;

要么取引用,类似于
auto& task = map[i];

不然如果直接
auto task = map[i];
得到的是map[i]的拷贝对象,修改task的属性后不会改变map[i]中的对象的属性