@@ -1160,9 +1160,8 @@ struct _Iterator_base0 {
1160
1160
// CLASS _Container_proxy
1161
1161
struct _Container_base12;
1162
1162
struct _Container_proxy { // store head of iterator chain and back pointer
1163
- _CONSTEXPR20_DYNALLOC _Container_proxy() noexcept : _Mycont(nullptr), _Myfirstiter(nullptr) {}
1164
- _CONSTEXPR20_DYNALLOC _Container_proxy(_Container_base12* _Mycont_) noexcept
1165
- : _Mycont(_Mycont_), _Myfirstiter(nullptr) {}
1163
+ _CONSTEXPR20 _Container_proxy() noexcept : _Mycont(nullptr), _Myfirstiter(nullptr) {}
1164
+ _CONSTEXPR20 _Container_proxy(_Container_base12* _Mycont_) noexcept : _Mycont(_Mycont_), _Myfirstiter(nullptr) {}
1166
1165
1167
1166
const _Container_base12* _Mycont;
1168
1167
_Iterator_base12* _Myfirstiter;
@@ -1198,8 +1197,10 @@ public:
1198
1197
_Container_proxy* _Myproxy;
1199
1198
1200
1199
private:
1201
- inline void _Orphan_all_impl() noexcept;
1202
- inline void _Swap_proxy_and_iterators_impl(_Container_base12&) noexcept;
1200
+ _CONSTEXPR20_DYNALLOC void _Orphan_all_unlocked() noexcept;
1201
+ inline void _Orphan_all_locked() noexcept;
1202
+ _CONSTEXPR20_DYNALLOC void _Swap_proxy_and_iterators_unlocked(_Container_base12&) noexcept;
1203
+ inline void _Swap_proxy_and_iterators_locked(_Container_base12&) noexcept;
1203
1204
};
1204
1205
1205
1206
struct _Iterator_base12 { // store links to container proxy, next iterator
@@ -1212,75 +1213,91 @@ struct _Iterator_base12 { // store links to container proxy, next iterator
1212
1213
}
1213
1214
1214
1215
_CONSTEXPR20_DYNALLOC _Iterator_base12& operator=(const _Iterator_base12& _Right) noexcept {
1215
- #ifdef __cpp_lib_is_constant_evaluated
1216
- if (!_STD is_constant_evaluated())
1217
- #endif // __cpp_lib_is_constant_evaluated
1218
- {
1219
- if (_Myproxy != _Right._Myproxy) {
1220
- if (_Right._Myproxy) {
1221
- _Adopt(_Right._Myproxy->_Mycont);
1222
- } else { // becoming invalid, disown current parent
1216
+ if (_Myproxy != _Right._Myproxy) {
1217
+ if (_Right._Myproxy) {
1218
+ _Adopt(_Right._Myproxy->_Mycont);
1219
+ } else { // becoming invalid, disown current parent
1223
1220
#if _ITERATOR_DEBUG_LEVEL == 2
1224
- _Orphan_me();
1221
+ _Orphan_me();
1225
1222
#else // _ITERATOR_DEBUG_LEVEL == 2
1226
- _Myproxy = nullptr;
1223
+ _Myproxy = nullptr;
1227
1224
#endif // _ITERATOR_DEBUG_LEVEL == 2
1228
- }
1229
1225
}
1230
1226
}
1231
1227
return *this;
1232
1228
}
1233
1229
1234
1230
#if _ITERATOR_DEBUG_LEVEL == 2
1235
1231
_CONSTEXPR20_DYNALLOC ~_Iterator_base12() noexcept {
1236
- #ifdef __cpp_lib_is_constant_evaluated
1237
- if (!_STD is_constant_evaluated())
1238
- #endif // __cpp_lib_is_constant_evaluated
1239
- {
1240
- _Orphan_me();
1241
- }
1242
- #if _HAS_CXX20 && defined(__clang__) // TRANSITION: LLVM-XXXX
1243
- else {
1244
- [[maybe_unused]] volatile auto _Guard = _Myproxy;
1232
+ _Orphan_me();
1233
+ }
1234
+
1235
+ _CONSTEXPR20_DYNALLOC void _Adopt_unlocked(_Container_proxy* _Parent_proxy) noexcept {
1236
+ if (_Myproxy) { // adopted, remove self from list
1237
+ _Orphan_me_unlocked();
1245
1238
}
1246
- #endif // _HAS_CXX20 && defined(__clang__)
1239
+ _Mynextiter = _Parent_proxy->_Myfirstiter;
1240
+ _Parent_proxy->_Myfirstiter = this;
1241
+ _Myproxy = _Parent_proxy;
1247
1242
}
1248
- #endif // _ITERATOR_DEBUG_LEVEL == 2
1249
1243
1250
- #if _ITERATOR_DEBUG_LEVEL == 2
1251
- void _Adopt_impl(const _Container_base12* _Parent) noexcept {
1252
- if (_Parent) {
1253
- // have a parent, do adoption
1244
+ void _Adopt_locked(_Container_proxy* _Parent_proxy) noexcept {
1245
+ _Lockit _Lock(_LOCK_DEBUG);
1246
+ _Adopt_unlocked(_Parent_proxy);
1247
+ }
1248
+
1249
+ _CONSTEXPR20_DYNALLOC void _Adopt(const _Container_base12* _Parent) noexcept {
1250
+ if (_Parent) { // have a parent, do adoption
1254
1251
_Container_proxy* _Parent_proxy = _Parent->_Myproxy;
1255
1252
if (_Myproxy != _Parent_proxy) { // change parentage
1256
- _Orphan_me();
1257
- _Lockit _Lock(_LOCK_DEBUG);
1258
- _Mynextiter = _Parent_proxy->_Myfirstiter;
1259
- _Parent_proxy->_Myfirstiter = this;
1260
- _Myproxy = _Parent_proxy;
1253
+ #ifdef __cpp_lib_is_constant_evaluated
1254
+ if (_STD is_constant_evaluated()) {
1255
+ _Adopt_unlocked(_Parent_proxy);
1256
+ } else
1257
+ #endif // __cpp_lib_is_constant_evaluated
1258
+ {
1259
+ _Adopt_locked(_Parent_proxy);
1260
+ }
1261
1261
}
1262
- } else {
1263
- // no future parent, just disown current parent
1262
+ } else { // no future parent, just disown current parent
1264
1263
_Orphan_me();
1265
1264
}
1266
1265
}
1267
1266
1268
- _CONSTEXPR20_DYNALLOC void _Adopt(const _Container_base12* _Parent) noexcept {
1267
+ _CONSTEXPR20_DYNALLOC void _Orphan_me_unlocked() noexcept {
1268
+ _Iterator_base12** _Pnext = &_Myproxy->_Myfirstiter;
1269
+ while (*_Pnext && *_Pnext != this) {
1270
+ _Pnext = &(*_Pnext)->_Mynextiter;
1271
+ }
1272
+
1273
+ _STL_VERIFY(*_Pnext, "ITERATOR LIST CORRUPTED!");
1274
+ *_Pnext = _Mynextiter;
1275
+ _Myproxy = nullptr;
1276
+ }
1277
+
1278
+ void _Orphan_me_locked() noexcept {
1279
+ _Lockit _Lock(_LOCK_DEBUG);
1280
+ _Orphan_me_unlocked();
1281
+ }
1282
+
1283
+ _CONSTEXPR20_DYNALLOC void _Orphan_me() noexcept {
1284
+ if (_Myproxy) { // adopted, remove self from list
1269
1285
#ifdef __cpp_lib_is_constant_evaluated
1270
- if (!_STD is_constant_evaluated())
1286
+ if (_STD is_constant_evaluated()) {
1287
+ _Orphan_me_unlocked();
1288
+ } else
1271
1289
#endif // __cpp_lib_is_constant_evaluated
1272
- {
1273
- _Adopt_impl(_Parent);
1290
+ {
1291
+ _Orphan_me_locked();
1292
+ }
1274
1293
}
1275
1294
}
1295
+
1276
1296
#else // ^^^ _ITERATOR_DEBUG_LEVEL == 2 ^^^ / vvv _ITERATOR_DEBUG_LEVEL != 2 vvv
1277
1297
_CONSTEXPR20_DYNALLOC void _Adopt(const _Container_base12* _Parent) noexcept {
1278
- if (_Parent) {
1279
- // have a parent, do adoption
1280
- _Container_proxy* _Parent_proxy = _Parent->_Myproxy;
1281
- _Myproxy = _Parent_proxy;
1282
- } else {
1283
- // no future parent, just disown current parent
1298
+ if (_Parent) { // have a parent, do adoption
1299
+ _Myproxy = _Parent->_Myproxy;
1300
+ } else { // no future parent, just disown current parent
1284
1301
_Myproxy = nullptr;
1285
1302
}
1286
1303
}
@@ -1290,55 +1307,41 @@ struct _Iterator_base12 { // store links to container proxy, next iterator
1290
1307
return _Myproxy ? _Myproxy->_Mycont : nullptr;
1291
1308
}
1292
1309
1293
- #if _ITERATOR_DEBUG_LEVEL == 2
1294
- void _Orphan_me() noexcept {
1295
- _Lockit _Lock(_LOCK_DEBUG);
1296
- if (_Myproxy) { // adopted, remove self from list
1297
- _Iterator_base12** _Pnext = &_Myproxy->_Myfirstiter;
1298
- while (*_Pnext && *_Pnext != this) {
1299
- _Pnext = &(*_Pnext)->_Mynextiter;
1300
- }
1301
-
1302
- _STL_VERIFY(*_Pnext, "ITERATOR LIST CORRUPTED!");
1303
- *_Pnext = _Mynextiter;
1304
- _Myproxy = nullptr;
1305
- }
1306
- }
1307
- #endif // _ITERATOR_DEBUG_LEVEL == 2
1308
-
1309
1310
static constexpr bool _Unwrap_when_unverified = _ITERATOR_DEBUG_LEVEL == 0;
1310
1311
1311
1312
_Container_proxy* _Myproxy;
1312
1313
_Iterator_base12* _Mynextiter;
1313
1314
};
1314
1315
1315
1316
// MEMBER FUNCTIONS FOR _Container_base12
1316
- inline void _Container_base12::_Orphan_all_impl() noexcept {
1317
- if (_Myproxy) { // proxy allocated, drain it
1318
- _Lockit _Lock(_LOCK_DEBUG);
1319
- for (auto _Pnext = &_Myproxy->_Myfirstiter; *_Pnext; *_Pnext = (*_Pnext)->_Mynextiter) {
1320
- (*_Pnext)->_Myproxy = nullptr;
1321
- }
1322
-
1323
- _Myproxy->_Myfirstiter = nullptr;
1317
+ _CONSTEXPR20_DYNALLOC void _Container_base12::_Orphan_all_unlocked() noexcept {
1318
+ for (auto _Pnext = &_Myproxy->_Myfirstiter; *_Pnext; *_Pnext = (*_Pnext)->_Mynextiter) {
1319
+ (*_Pnext)->_Myproxy = nullptr;
1324
1320
}
1321
+ _Myproxy->_Myfirstiter = nullptr;
1322
+ }
1323
+
1324
+ inline void _Container_base12::_Orphan_all_locked() noexcept {
1325
+ _Lockit _Lock(_LOCK_DEBUG);
1326
+ _Orphan_all_unlocked();
1325
1327
}
1326
1328
1327
1329
_CONSTEXPR20_DYNALLOC void _Container_base12::_Orphan_all() noexcept {
1328
1330
#if _ITERATOR_DEBUG_LEVEL == 2
1331
+ if (_Myproxy) { // proxy allocated, drain it
1329
1332
#ifdef __cpp_lib_is_constant_evaluated
1330
- if (!_STD is_constant_evaluated())
1333
+ if (_STD is_constant_evaluated()) {
1334
+ _Orphan_all_unlocked();
1335
+ } else
1331
1336
#endif // __cpp_lib_is_constant_evaluated
1332
- {
1333
- _Orphan_all_impl();
1337
+ {
1338
+ _Orphan_all_locked();
1339
+ }
1334
1340
}
1335
1341
#endif // _ITERATOR_DEBUG_LEVEL == 2
1336
1342
}
1337
1343
1338
- inline void _Container_base12::_Swap_proxy_and_iterators_impl(_Container_base12& _Right) noexcept {
1339
- #if _ITERATOR_DEBUG_LEVEL == 2
1340
- _Lockit _Lock(_LOCK_DEBUG);
1341
- #endif // _ITERATOR_DEBUG_LEVEL == 2
1344
+ _CONSTEXPR20_DYNALLOC void _Container_base12::_Swap_proxy_and_iterators_unlocked(_Container_base12& _Right) noexcept {
1342
1345
_Container_proxy* _Temp = _Myproxy;
1343
1346
_Myproxy = _Right._Myproxy;
1344
1347
_Right._Myproxy = _Temp;
@@ -1352,13 +1355,24 @@ inline void _Container_base12::_Swap_proxy_and_iterators_impl(_Container_base12&
1352
1355
}
1353
1356
}
1354
1357
1358
+ inline void _Container_base12::_Swap_proxy_and_iterators_locked(_Container_base12& _Right) noexcept {
1359
+ _Lockit _Lock(_LOCK_DEBUG);
1360
+ _Swap_proxy_and_iterators_unlocked(_Right);
1361
+ }
1362
+
1355
1363
_CONSTEXPR20_DYNALLOC void _Container_base12::_Swap_proxy_and_iterators(_Container_base12& _Right) noexcept {
1364
+ #if _ITERATOR_DEBUG_LEVEL != 2
1365
+ _Swap_proxy_and_iterators_unlocked(_Right);
1366
+ #else // ^^^ _ITERATOR_DEBUG_LEVEL != 2 ^^^ / vvv _ITERATOR_DEBUG_LEVEL == 2 vvv
1356
1367
#ifdef __cpp_lib_is_constant_evaluated
1357
- if (!_STD is_constant_evaluated())
1368
+ if (_STD is_constant_evaluated()) {
1369
+ _Swap_proxy_and_iterators_unlocked(_Right);
1370
+ } else
1358
1371
#endif // __cpp_lib_is_constant_evaluated
1359
1372
{
1360
- _Swap_proxy_and_iterators_impl (_Right);
1373
+ _Swap_proxy_and_iterators_locked (_Right);
1361
1374
}
1375
+ #endif // _ITERATOR_DEBUG_LEVEL == 2
1362
1376
}
1363
1377
1364
1378
#if _ITERATOR_DEBUG_LEVEL == 0
0 commit comments