In gcc vector.tcc::_M_fill_insert function (line524), the implementation uses
- case 1:
__uninitialized_move_a
(line562) for case of uninitialized but existing memory; - case 2:
__uninitialized_move_if_noexcept_a
(line580) for newly allocated memory.
I am wondering why __uninitialized_move_if_noexcept_a
has not been used in case1: there is no guarantee that the copy constructor or move constructor is noexcept. If copy constructor failed, the original vector could be recovered; if move constructor throws exception, the original vector will be in a unclear state?