@@ -819,7 +819,6 @@ public:
819
819
820
820
template <class _InputIterator , class _Sentinel >
821
821
_LIBCPP_HIDE_FROM_ABI iterator __insert_after_with_sentinel (const_iterator __p, _InputIterator __f, _Sentinel __l);
822
- _LIBCPP_HIDE_FROM_ABI iterator __default_insert_after (const_iterator __p, size_type __n);
823
822
824
823
_LIBCPP_HIDE_FROM_ABI iterator erase_after (const_iterator __p);
825
824
_LIBCPP_HIDE_FROM_ABI iterator erase_after (const_iterator __f, const_iterator __l);
@@ -1129,36 +1128,6 @@ forward_list<_Tp, _Alloc>::insert_after(const_iterator __p, const value_type& __
1129
1128
return iterator (__r->__next_ );
1130
1129
}
1131
1130
1132
- template <class _Tp , class _Alloc >
1133
- typename forward_list<_Tp, _Alloc>::iterator
1134
- forward_list<_Tp, _Alloc>::__default_insert_after(const_iterator __p, size_type __n) {
1135
- __begin_node_pointer __r = __p.__get_begin ();
1136
- if (__n > 0 ) {
1137
- __node_pointer __first = this ->__create_node (/* next = */ nullptr );
1138
- __node_pointer __last = __first;
1139
- # if _LIBCPP_HAS_EXCEPTIONS
1140
- try {
1141
- # endif // _LIBCPP_HAS_EXCEPTIONS
1142
- for (--__n; __n != 0 ; --__n, __last = __last->__next_ ) {
1143
- __last->__next_ = this ->__create_node (/* next = */ nullptr );
1144
- }
1145
- # if _LIBCPP_HAS_EXCEPTIONS
1146
- } catch (...) {
1147
- while (__first != nullptr ) {
1148
- __node_pointer __next = __first->__next_ ;
1149
- this ->__delete_node (__first);
1150
- __first = __next;
1151
- }
1152
- throw ;
1153
- }
1154
- # endif // _LIBCPP_HAS_EXCEPTIONS
1155
- __last->__next_ = __r->__next_ ;
1156
- __r->__next_ = __first;
1157
- __r = static_cast <__begin_node_pointer>(__last);
1158
- }
1159
- return iterator (__r);
1160
- }
1161
-
1162
1131
template <class _Tp , class _Alloc >
1163
1132
typename forward_list<_Tp, _Alloc>::iterator
1164
1133
forward_list<_Tp, _Alloc>::insert_after(const_iterator __p, size_type __n, const value_type& __v) {
@@ -1271,7 +1240,31 @@ void forward_list<_Tp, _Alloc>::resize(size_type __n) {
1271
1240
if (__i != __e)
1272
1241
erase_after (__p, __e);
1273
1242
else {
1274
- __default_insert_after (__p, __n - __sz);
1243
+ __n -= __sz;
1244
+ __begin_node_pointer __r = __p.__get_begin ();
1245
+ if (__n > 0 ) {
1246
+ __node_pointer __first = this ->__create_node (/* next = */ nullptr );
1247
+ __node_pointer __last = __first;
1248
+ # if _LIBCPP_HAS_EXCEPTIONS
1249
+ try {
1250
+ # endif // _LIBCPP_HAS_EXCEPTIONS
1251
+ for (--__n; __n != 0 ; --__n, __last = __last->__next_ ) {
1252
+ __last->__next_ = this ->__create_node (/* next = */ nullptr );
1253
+ }
1254
+ # if _LIBCPP_HAS_EXCEPTIONS
1255
+ } catch (...) {
1256
+ while (__first != nullptr ) {
1257
+ __node_pointer __next = __first->__next_ ;
1258
+ this ->__delete_node (__first);
1259
+ __first = __next;
1260
+ }
1261
+ throw ;
1262
+ }
1263
+ # endif // _LIBCPP_HAS_EXCEPTIONS
1264
+ __last->__next_ = __r->__next_ ;
1265
+ __r->__next_ = __first;
1266
+ __r = static_cast <__begin_node_pointer>(__last);
1267
+ }
1275
1268
}
1276
1269
}
1277
1270
0 commit comments