345 {
346 constexpr ERRCODE DONT_EXCHANGE_DELETED(
347 "Can't exchange deleted elements of lists");
348
350
351 #ifndef NDEBUG
352 if (!list)
354 if (!other_it)
356 if (!(other_it->list))
358 #endif
359
360
361
362
363 if ((list->
empty ()) ||
364 (other_it->list->
empty ()) || (current == other_it->current))
365 return;
366
367
368
369 if (!current || !other_it->current)
370 DONT_EXCHANGE_DELETED.error (
"CLIST_ITERATOR.exchange",
ABORT,
nullptr);
371
372
373
374
375
376
377 if ((next == other_it->current) ||
378 (other_it->next == current)) {
379
380 if ((next == other_it->current) &&
381 (other_it->next == current)) {
382 prev = next = current;
383 other_it->prev = other_it->next = other_it->current;
384 }
385 else {
386
387
388 if (other_it->next == current) {
389 other_it->prev->next = current;
390 other_it->current->next = next;
391 current->next = other_it->current;
392 other_it->next = other_it->current;
393 prev = current;
394 }
395 else {
396 prev->next = other_it->current;
397 current->next = other_it->next;
398 other_it->current->next = current;
399 next = current;
400 other_it->prev = other_it->current;
401 }
402 }
403 }
404 else {
405 prev->next = other_it->current;
406 current->next = other_it->next;
407 other_it->prev->next = current;
408 other_it->current->next = next;
409 }
410
411
412
413
414 if (list->last == current)
415 list->last = other_it->current;
416 if (other_it->list->last == other_it->current)
417 other_it->list->last = current;
418
419 if (current == cycle_pt)
420 cycle_pt = other_it->cycle_pt;
421 if (other_it->current == other_it->cycle_pt)
422 other_it->cycle_pt = cycle_pt;
423
424
425
426 old_current = current;
427 current = other_it->current;
428 other_it->current = old_current;
429}