C++ STL 的 copy() 异常安全

标签 c++ exception stl

如果我这样做了

std::copy(source, source + size, destination);

我有强大的异常安全保证吗? IE。如果 std::copy 抛出,destination 保持不变?

最佳答案

附录 E:标准库异常安全来自 Stroustrop 的 C++ 编程语言freely viewable from his website .

由此而来:

The copy() algorithm (§18.6.1) does not offer the strong exception-safety guarantee. It does not guarantee that it will leave its target unchanged if an exception is thrown during copying

关于C++ STL 的 copy() 异常安全,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29016785/

相关文章:

c++ - C++ 程序如何工作?

exception - log4j2 异常处理不起作用

python 基础 try catch 异常

c# - 我应该强制异常(exception)来测试它们吗?

c++ - 如何初始化 std::map 项的 std::vector?

c++ - 为什么 std::remove_if 创建这么多闭包?

c++ sort 会崩溃,而 stable_sort 不会,但两者都不起作用

c++ - 分割 vector 的有效方法是什么

c++ - OpenMP C++ : Load imbalance with parallelised for loop

c++ - 通过特定定制环绕世界边缘