MyTinySTL
MyTinySTL copied to clipboard
unchecked_uninit_move 如果发生异常如何处理已经移动的元素
https://github.com/Alinshans/MyTinySTL/blob/8d88c6e41590e49fb91782711f78d8ab1d5e88e4/MyTinySTL/uninitialized.h#L194 请问大佬,unchecked_uninit_move这个函数如果vector的 reallocate_emplace 调用了该函数,但是移动了一部分的元素发生了异常,这时候那部分已经移动的元素该怎么处理呢,我看这个函数是光destory了新对象,但是并没有throw
似乎不用处理,标准库中实际的实现也是这样的,可以看一下uninitialized_move的文档 里面有这么说: If an exception is thrown during the initialization, some objects in the source range are left in a valid but unspecified state, and the objects already constructed are destroyed in an unspecified order.