-
20 votesanswersviews
将emplace_back与unique_ptrs容器一起使用是否安全?
考虑以下: std::vector<std::unique_ptr<int>> ptrsToInts; ptrsToInts.emplace_back(new int); 如果在向量中发生重新分配,并且失败(抛出 std::bad_alloc ),我是"safe"还是会泄漏 int ? C 11 23.3.6.5 [vector.modifiers] ...