关于uninitialized.h异常处理问题
作者: YuukaBkkl创建于 2025年10月13日更新于 2025年10月18日
template <class InputIter, class ForwardIter> ForwardIter unchecked_uninit_copy(InputIter first, InputIter last, ForwardIter result, std::false_type) { auto cur = result; try { for (; first != last; ++first, ++cur) { mystl::construct(&*cur, *first); } } catch (...) { for (; result != cur; --cur) mystl::destroy(&*cur); } return cur; Personally, I think the --cur in the exception-handling for loop should be inside the function body, otherwise the destruction location is incorrect.
内容来源: Alinshans/MyTinySTL