c++ - When std::vector reallocate its memory array, is copy constructor or move constructor used? -
when std::vector reallocate memory array, kind of copy / move constructor used copy / move elements new houses?
if move-constructor exists , noexcept
used. otherwise copy-constructor used.
using move-constructor might throw undesirable might happen objects moved new storage , exception prevents rest of objects being moved.
the cppreference.com site if object non-copyable , has non-noexcept move constructor, use move-constructor, "unspecified behaviour" if exception thrown. guess means elements may lost vector.
Comments
Post a Comment