1 //===----------------------------------------------------------------------===// 2 // 3 // The LLVM Compiler Infrastructure 4 // 5 // This file is dual licensed under the MIT and the University of Illinois Open 6 // Source Licenses. See LICENSE.TXT for details. 7 // 8 //===----------------------------------------------------------------------===// 9 10 // <list> 11 12 // void splice(const_iterator position, list& x); 13 14 #if _LIBCPP_DEBUG >= 1 15 #define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) 16 #endif 17 18 #include <list> 19 #include <cassert> 20 21 #include "min_allocator.h" 22 23 int main() 24 { 25 int a1[] = {1, 2, 3}; 26 int a2[] = {4, 5, 6}; 27 { 28 std::list<int> l1; 29 std::list<int> l2; 30 l1.splice(l1.end(), l2); 31 assert(l1.size() == 0); 32 assert(distance(l1.begin(), l1.end()) == 0); 33 assert(l2.size() == 0); 34 assert(distance(l2.begin(), l2.end()) == 0); 35 } 36 { 37 std::list<int> l1; 38 std::list<int> l2(a2, a2+1); 39 l1.splice(l1.end(), l2); 40 assert(l1.size() == 1); 41 assert(distance(l1.begin(), l1.end()) == 1); 42 assert(l2.size() == 0); 43 assert(distance(l2.begin(), l2.end()) == 0); 44 std::list<int>::const_iterator i = l1.begin(); 45 assert(*i == 4); 46 } 47 { 48 std::list<int> l1; 49 std::list<int> l2(a2, a2+2); 50 l1.splice(l1.end(), l2); 51 assert(l1.size() == 2); 52 assert(distance(l1.begin(), l1.end()) == 2); 53 assert(l2.size() == 0); 54 assert(distance(l2.begin(), l2.end()) == 0); 55 std::list<int>::const_iterator i = l1.begin(); 56 assert(*i == 4); 57 ++i; 58 assert(*i == 5); 59 } 60 { 61 std::list<int> l1; 62 std::list<int> l2(a2, a2+3); 63 l1.splice(l1.end(), l2); 64 assert(l1.size() == 3); 65 assert(distance(l1.begin(), l1.end()) == 3); 66 assert(l2.size() == 0); 67 assert(distance(l2.begin(), l2.end()) == 0); 68 std::list<int>::const_iterator i = l1.begin(); 69 assert(*i == 4); 70 ++i; 71 assert(*i == 5); 72 ++i; 73 assert(*i == 6); 74 } 75 { 76 std::list<int> l1(a1, a1+1); 77 std::list<int> l2; 78 l1.splice(l1.begin(), l2); 79 assert(l1.size() == 1); 80 assert(distance(l1.begin(), l1.end()) == 1); 81 assert(l2.size() == 0); 82 assert(distance(l2.begin(), l2.end()) == 0); 83 std::list<int>::const_iterator i = l1.begin(); 84 assert(*i == 1); 85 } 86 { 87 std::list<int> l1(a1, a1+1); 88 std::list<int> l2; 89 l1.splice(l1.end(), l2); 90 assert(l1.size() == 1); 91 assert(distance(l1.begin(), l1.end()) == 1); 92 assert(l2.size() == 0); 93 assert(distance(l2.begin(), l2.end()) == 0); 94 std::list<int>::const_iterator i = l1.begin(); 95 assert(*i == 1); 96 } 97 { 98 std::list<int> l1(a1, a1+1); 99 std::list<int> l2(a2, a2+1); 100 l1.splice(l1.begin(), l2); 101 assert(l1.size() == 2); 102 assert(distance(l1.begin(), l1.end()) == 2); 103 assert(l2.size() == 0); 104 assert(distance(l2.begin(), l2.end()) == 0); 105 std::list<int>::const_iterator i = l1.begin(); 106 assert(*i == 4); 107 ++i; 108 assert(*i == 1); 109 } 110 { 111 std::list<int> l1(a1, a1+1); 112 std::list<int> l2(a2, a2+1); 113 l1.splice(l1.end(), l2); 114 assert(l1.size() == 2); 115 assert(distance(l1.begin(), l1.end()) == 2); 116 assert(l2.size() == 0); 117 assert(distance(l2.begin(), l2.end()) == 0); 118 std::list<int>::const_iterator i = l1.begin(); 119 assert(*i == 1); 120 ++i; 121 assert(*i == 4); 122 } 123 { 124 std::list<int> l1(a1, a1+1); 125 std::list<int> l2(a2, a2+2); 126 l1.splice(l1.begin(), l2); 127 assert(l1.size() == 3); 128 assert(distance(l1.begin(), l1.end()) == 3); 129 assert(l2.size() == 0); 130 assert(distance(l2.begin(), l2.end()) == 0); 131 std::list<int>::const_iterator i = l1.begin(); 132 assert(*i == 4); 133 ++i; 134 assert(*i == 5); 135 ++i; 136 assert(*i == 1); 137 } 138 { 139 std::list<int> l1(a1, a1+1); 140 std::list<int> l2(a2, a2+2); 141 l1.splice(l1.end(), l2); 142 assert(l1.size() == 3); 143 assert(distance(l1.begin(), l1.end()) == 3); 144 assert(l2.size() == 0); 145 assert(distance(l2.begin(), l2.end()) == 0); 146 std::list<int>::const_iterator i = l1.begin(); 147 assert(*i == 1); 148 ++i; 149 assert(*i == 4); 150 ++i; 151 assert(*i == 5); 152 } 153 { 154 std::list<int> l1(a1, a1+1); 155 std::list<int> l2(a2, a2+3); 156 l1.splice(l1.begin(), l2); 157 assert(l1.size() == 4); 158 assert(distance(l1.begin(), l1.end()) == 4); 159 assert(l2.size() == 0); 160 assert(distance(l2.begin(), l2.end()) == 0); 161 std::list<int>::const_iterator i = l1.begin(); 162 assert(*i == 4); 163 ++i; 164 assert(*i == 5); 165 ++i; 166 assert(*i == 6); 167 ++i; 168 assert(*i == 1); 169 } 170 { 171 std::list<int> l1(a1, a1+1); 172 std::list<int> l2(a2, a2+3); 173 l1.splice(l1.end(), l2); 174 assert(l1.size() == 4); 175 assert(distance(l1.begin(), l1.end()) == 4); 176 assert(l2.size() == 0); 177 assert(distance(l2.begin(), l2.end()) == 0); 178 std::list<int>::const_iterator i = l1.begin(); 179 assert(*i == 1); 180 ++i; 181 assert(*i == 4); 182 ++i; 183 assert(*i == 5); 184 ++i; 185 assert(*i == 6); 186 } 187 { 188 std::list<int> l1(a1, a1+2); 189 std::list<int> l2; 190 l1.splice(l1.begin(), l2); 191 assert(l1.size() == 2); 192 assert(distance(l1.begin(), l1.end()) == 2); 193 assert(l2.size() == 0); 194 assert(distance(l2.begin(), l2.end()) == 0); 195 std::list<int>::const_iterator i = l1.begin(); 196 assert(*i == 1); 197 ++i; 198 assert(*i == 2); 199 } 200 { 201 std::list<int> l1(a1, a1+2); 202 std::list<int> l2; 203 l1.splice(next(l1.begin()), l2); 204 assert(l1.size() == 2); 205 assert(distance(l1.begin(), l1.end()) == 2); 206 assert(l2.size() == 0); 207 assert(distance(l2.begin(), l2.end()) == 0); 208 std::list<int>::const_iterator i = l1.begin(); 209 assert(*i == 1); 210 ++i; 211 assert(*i == 2); 212 } 213 { 214 std::list<int> l1(a1, a1+2); 215 std::list<int> l2; 216 l1.splice(next(l1.begin(), 2), l2); 217 assert(l1.size() == 2); 218 assert(distance(l1.begin(), l1.end()) == 2); 219 assert(l2.size() == 0); 220 assert(distance(l2.begin(), l2.end()) == 0); 221 std::list<int>::const_iterator i = l1.begin(); 222 assert(*i == 1); 223 ++i; 224 assert(*i == 2); 225 } 226 { 227 std::list<int> l1(a1, a1+2); 228 std::list<int> l2(a2, a2+1); 229 l1.splice(l1.begin(), l2); 230 assert(l1.size() == 3); 231 assert(distance(l1.begin(), l1.end()) == 3); 232 assert(l2.size() == 0); 233 assert(distance(l2.begin(), l2.end()) == 0); 234 std::list<int>::const_iterator i = l1.begin(); 235 assert(*i == 4); 236 ++i; 237 assert(*i == 1); 238 ++i; 239 assert(*i == 2); 240 } 241 { 242 std::list<int> l1(a1, a1+2); 243 std::list<int> l2(a2, a2+1); 244 l1.splice(next(l1.begin()), l2); 245 assert(l1.size() == 3); 246 assert(distance(l1.begin(), l1.end()) == 3); 247 assert(l2.size() == 0); 248 assert(distance(l2.begin(), l2.end()) == 0); 249 std::list<int>::const_iterator i = l1.begin(); 250 assert(*i == 1); 251 ++i; 252 assert(*i == 4); 253 ++i; 254 assert(*i == 2); 255 } 256 { 257 std::list<int> l1(a1, a1+2); 258 std::list<int> l2(a2, a2+1); 259 l1.splice(next(l1.begin(), 2), l2); 260 assert(l1.size() == 3); 261 assert(distance(l1.begin(), l1.end()) == 3); 262 assert(l2.size() == 0); 263 assert(distance(l2.begin(), l2.end()) == 0); 264 std::list<int>::const_iterator i = l1.begin(); 265 assert(*i == 1); 266 ++i; 267 assert(*i == 2); 268 ++i; 269 assert(*i == 4); 270 } 271 { 272 std::list<int> l1(a1, a1+2); 273 std::list<int> l2(a2, a2+2); 274 l1.splice(l1.begin(), l2); 275 assert(l1.size() == 4); 276 assert(distance(l1.begin(), l1.end()) == 4); 277 assert(l2.size() == 0); 278 assert(distance(l2.begin(), l2.end()) == 0); 279 std::list<int>::const_iterator i = l1.begin(); 280 assert(*i == 4); 281 ++i; 282 assert(*i == 5); 283 ++i; 284 assert(*i == 1); 285 ++i; 286 assert(*i == 2); 287 } 288 { 289 std::list<int> l1(a1, a1+2); 290 std::list<int> l2(a2, a2+2); 291 l1.splice(next(l1.begin()), l2); 292 assert(l1.size() == 4); 293 assert(distance(l1.begin(), l1.end()) == 4); 294 assert(l2.size() == 0); 295 assert(distance(l2.begin(), l2.end()) == 0); 296 std::list<int>::const_iterator i = l1.begin(); 297 assert(*i == 1); 298 ++i; 299 assert(*i == 4); 300 ++i; 301 assert(*i == 5); 302 ++i; 303 assert(*i == 2); 304 } 305 { 306 std::list<int> l1(a1, a1+2); 307 std::list<int> l2(a2, a2+2); 308 l1.splice(next(l1.begin(), 2), l2); 309 assert(l1.size() == 4); 310 assert(distance(l1.begin(), l1.end()) == 4); 311 assert(l2.size() == 0); 312 assert(distance(l2.begin(), l2.end()) == 0); 313 std::list<int>::const_iterator i = l1.begin(); 314 assert(*i == 1); 315 ++i; 316 assert(*i == 2); 317 ++i; 318 assert(*i == 4); 319 ++i; 320 assert(*i == 5); 321 } 322 { 323 std::list<int> l1(a1, a1+3); 324 std::list<int> l2(a2, a2+3); 325 l1.splice(l1.begin(), l2); 326 assert(l1.size() == 6); 327 assert(distance(l1.begin(), l1.end()) == 6); 328 assert(l2.size() == 0); 329 assert(distance(l2.begin(), l2.end()) == 0); 330 std::list<int>::const_iterator i = l1.begin(); 331 assert(*i == 4); 332 ++i; 333 assert(*i == 5); 334 ++i; 335 assert(*i == 6); 336 ++i; 337 assert(*i == 1); 338 ++i; 339 assert(*i == 2); 340 ++i; 341 assert(*i == 3); 342 } 343 { 344 std::list<int> l1(a1, a1+3); 345 std::list<int> l2(a2, a2+3); 346 l1.splice(next(l1.begin()), l2); 347 assert(l1.size() == 6); 348 assert(distance(l1.begin(), l1.end()) == 6); 349 assert(l2.size() == 0); 350 assert(distance(l2.begin(), l2.end()) == 0); 351 std::list<int>::const_iterator i = l1.begin(); 352 assert(*i == 1); 353 ++i; 354 assert(*i == 4); 355 ++i; 356 assert(*i == 5); 357 ++i; 358 assert(*i == 6); 359 ++i; 360 assert(*i == 2); 361 ++i; 362 assert(*i == 3); 363 } 364 { 365 std::list<int> l1(a1, a1+3); 366 std::list<int> l2(a2, a2+3); 367 l1.splice(next(l1.begin(), 2), l2); 368 assert(l1.size() == 6); 369 assert(distance(l1.begin(), l1.end()) == 6); 370 assert(l2.size() == 0); 371 assert(distance(l2.begin(), l2.end()) == 0); 372 std::list<int>::const_iterator i = l1.begin(); 373 assert(*i == 1); 374 ++i; 375 assert(*i == 2); 376 ++i; 377 assert(*i == 4); 378 ++i; 379 assert(*i == 5); 380 ++i; 381 assert(*i == 6); 382 ++i; 383 assert(*i == 3); 384 } 385 { 386 std::list<int> l1(a1, a1+3); 387 std::list<int> l2(a2, a2+3); 388 l1.splice(next(l1.begin(), 3), l2); 389 assert(l1.size() == 6); 390 assert(distance(l1.begin(), l1.end()) == 6); 391 assert(l2.size() == 0); 392 assert(distance(l2.begin(), l2.end()) == 0); 393 std::list<int>::const_iterator i = l1.begin(); 394 assert(*i == 1); 395 ++i; 396 assert(*i == 2); 397 ++i; 398 assert(*i == 3); 399 ++i; 400 assert(*i == 4); 401 ++i; 402 assert(*i == 5); 403 ++i; 404 assert(*i == 6); 405 } 406 #if _LIBCPP_DEBUG >= 1 407 { 408 std::list<int> v1(3); 409 std::list<int> v2(3); 410 v1.splice(v2.begin(), v2); 411 assert(false); 412 } 413 #endif 414 #if __cplusplus >= 201103L 415 { 416 std::list<int, min_allocator<int>> l1; 417 std::list<int, min_allocator<int>> l2; 418 l1.splice(l1.end(), l2); 419 assert(l1.size() == 0); 420 assert(distance(l1.begin(), l1.end()) == 0); 421 assert(l2.size() == 0); 422 assert(distance(l2.begin(), l2.end()) == 0); 423 } 424 { 425 std::list<int, min_allocator<int>> l1; 426 std::list<int, min_allocator<int>> l2(a2, a2+1); 427 l1.splice(l1.end(), l2); 428 assert(l1.size() == 1); 429 assert(distance(l1.begin(), l1.end()) == 1); 430 assert(l2.size() == 0); 431 assert(distance(l2.begin(), l2.end()) == 0); 432 std::list<int, min_allocator<int>>::const_iterator i = l1.begin(); 433 assert(*i == 4); 434 } 435 { 436 std::list<int, min_allocator<int>> l1; 437 std::list<int, min_allocator<int>> l2(a2, a2+2); 438 l1.splice(l1.end(), l2); 439 assert(l1.size() == 2); 440 assert(distance(l1.begin(), l1.end()) == 2); 441 assert(l2.size() == 0); 442 assert(distance(l2.begin(), l2.end()) == 0); 443 std::list<int, min_allocator<int>>::const_iterator i = l1.begin(); 444 assert(*i == 4); 445 ++i; 446 assert(*i == 5); 447 } 448 { 449 std::list<int, min_allocator<int>> l1; 450 std::list<int, min_allocator<int>> l2(a2, a2+3); 451 l1.splice(l1.end(), l2); 452 assert(l1.size() == 3); 453 assert(distance(l1.begin(), l1.end()) == 3); 454 assert(l2.size() == 0); 455 assert(distance(l2.begin(), l2.end()) == 0); 456 std::list<int, min_allocator<int>>::const_iterator i = l1.begin(); 457 assert(*i == 4); 458 ++i; 459 assert(*i == 5); 460 ++i; 461 assert(*i == 6); 462 } 463 { 464 std::list<int, min_allocator<int>> l1(a1, a1+1); 465 std::list<int, min_allocator<int>> l2; 466 l1.splice(l1.begin(), l2); 467 assert(l1.size() == 1); 468 assert(distance(l1.begin(), l1.end()) == 1); 469 assert(l2.size() == 0); 470 assert(distance(l2.begin(), l2.end()) == 0); 471 std::list<int, min_allocator<int>>::const_iterator i = l1.begin(); 472 assert(*i == 1); 473 } 474 { 475 std::list<int, min_allocator<int>> l1(a1, a1+1); 476 std::list<int, min_allocator<int>> l2; 477 l1.splice(l1.end(), l2); 478 assert(l1.size() == 1); 479 assert(distance(l1.begin(), l1.end()) == 1); 480 assert(l2.size() == 0); 481 assert(distance(l2.begin(), l2.end()) == 0); 482 std::list<int, min_allocator<int>>::const_iterator i = l1.begin(); 483 assert(*i == 1); 484 } 485 { 486 std::list<int, min_allocator<int>> l1(a1, a1+1); 487 std::list<int, min_allocator<int>> l2(a2, a2+1); 488 l1.splice(l1.begin(), l2); 489 assert(l1.size() == 2); 490 assert(distance(l1.begin(), l1.end()) == 2); 491 assert(l2.size() == 0); 492 assert(distance(l2.begin(), l2.end()) == 0); 493 std::list<int, min_allocator<int>>::const_iterator i = l1.begin(); 494 assert(*i == 4); 495 ++i; 496 assert(*i == 1); 497 } 498 { 499 std::list<int, min_allocator<int>> l1(a1, a1+1); 500 std::list<int, min_allocator<int>> l2(a2, a2+1); 501 l1.splice(l1.end(), l2); 502 assert(l1.size() == 2); 503 assert(distance(l1.begin(), l1.end()) == 2); 504 assert(l2.size() == 0); 505 assert(distance(l2.begin(), l2.end()) == 0); 506 std::list<int, min_allocator<int>>::const_iterator i = l1.begin(); 507 assert(*i == 1); 508 ++i; 509 assert(*i == 4); 510 } 511 { 512 std::list<int, min_allocator<int>> l1(a1, a1+1); 513 std::list<int, min_allocator<int>> l2(a2, a2+2); 514 l1.splice(l1.begin(), l2); 515 assert(l1.size() == 3); 516 assert(distance(l1.begin(), l1.end()) == 3); 517 assert(l2.size() == 0); 518 assert(distance(l2.begin(), l2.end()) == 0); 519 std::list<int, min_allocator<int>>::const_iterator i = l1.begin(); 520 assert(*i == 4); 521 ++i; 522 assert(*i == 5); 523 ++i; 524 assert(*i == 1); 525 } 526 { 527 std::list<int, min_allocator<int>> l1(a1, a1+1); 528 std::list<int, min_allocator<int>> l2(a2, a2+2); 529 l1.splice(l1.end(), l2); 530 assert(l1.size() == 3); 531 assert(distance(l1.begin(), l1.end()) == 3); 532 assert(l2.size() == 0); 533 assert(distance(l2.begin(), l2.end()) == 0); 534 std::list<int, min_allocator<int>>::const_iterator i = l1.begin(); 535 assert(*i == 1); 536 ++i; 537 assert(*i == 4); 538 ++i; 539 assert(*i == 5); 540 } 541 { 542 std::list<int, min_allocator<int>> l1(a1, a1+1); 543 std::list<int, min_allocator<int>> l2(a2, a2+3); 544 l1.splice(l1.begin(), l2); 545 assert(l1.size() == 4); 546 assert(distance(l1.begin(), l1.end()) == 4); 547 assert(l2.size() == 0); 548 assert(distance(l2.begin(), l2.end()) == 0); 549 std::list<int, min_allocator<int>>::const_iterator i = l1.begin(); 550 assert(*i == 4); 551 ++i; 552 assert(*i == 5); 553 ++i; 554 assert(*i == 6); 555 ++i; 556 assert(*i == 1); 557 } 558 { 559 std::list<int, min_allocator<int>> l1(a1, a1+1); 560 std::list<int, min_allocator<int>> l2(a2, a2+3); 561 l1.splice(l1.end(), l2); 562 assert(l1.size() == 4); 563 assert(distance(l1.begin(), l1.end()) == 4); 564 assert(l2.size() == 0); 565 assert(distance(l2.begin(), l2.end()) == 0); 566 std::list<int, min_allocator<int>>::const_iterator i = l1.begin(); 567 assert(*i == 1); 568 ++i; 569 assert(*i == 4); 570 ++i; 571 assert(*i == 5); 572 ++i; 573 assert(*i == 6); 574 } 575 { 576 std::list<int, min_allocator<int>> l1(a1, a1+2); 577 std::list<int, min_allocator<int>> l2; 578 l1.splice(l1.begin(), l2); 579 assert(l1.size() == 2); 580 assert(distance(l1.begin(), l1.end()) == 2); 581 assert(l2.size() == 0); 582 assert(distance(l2.begin(), l2.end()) == 0); 583 std::list<int, min_allocator<int>>::const_iterator i = l1.begin(); 584 assert(*i == 1); 585 ++i; 586 assert(*i == 2); 587 } 588 { 589 std::list<int, min_allocator<int>> l1(a1, a1+2); 590 std::list<int, min_allocator<int>> l2; 591 l1.splice(next(l1.begin()), l2); 592 assert(l1.size() == 2); 593 assert(distance(l1.begin(), l1.end()) == 2); 594 assert(l2.size() == 0); 595 assert(distance(l2.begin(), l2.end()) == 0); 596 std::list<int, min_allocator<int>>::const_iterator i = l1.begin(); 597 assert(*i == 1); 598 ++i; 599 assert(*i == 2); 600 } 601 { 602 std::list<int, min_allocator<int>> l1(a1, a1+2); 603 std::list<int, min_allocator<int>> l2; 604 l1.splice(next(l1.begin(), 2), l2); 605 assert(l1.size() == 2); 606 assert(distance(l1.begin(), l1.end()) == 2); 607 assert(l2.size() == 0); 608 assert(distance(l2.begin(), l2.end()) == 0); 609 std::list<int, min_allocator<int>>::const_iterator i = l1.begin(); 610 assert(*i == 1); 611 ++i; 612 assert(*i == 2); 613 } 614 { 615 std::list<int, min_allocator<int>> l1(a1, a1+2); 616 std::list<int, min_allocator<int>> l2(a2, a2+1); 617 l1.splice(l1.begin(), l2); 618 assert(l1.size() == 3); 619 assert(distance(l1.begin(), l1.end()) == 3); 620 assert(l2.size() == 0); 621 assert(distance(l2.begin(), l2.end()) == 0); 622 std::list<int, min_allocator<int>>::const_iterator i = l1.begin(); 623 assert(*i == 4); 624 ++i; 625 assert(*i == 1); 626 ++i; 627 assert(*i == 2); 628 } 629 { 630 std::list<int, min_allocator<int>> l1(a1, a1+2); 631 std::list<int, min_allocator<int>> l2(a2, a2+1); 632 l1.splice(next(l1.begin()), l2); 633 assert(l1.size() == 3); 634 assert(distance(l1.begin(), l1.end()) == 3); 635 assert(l2.size() == 0); 636 assert(distance(l2.begin(), l2.end()) == 0); 637 std::list<int, min_allocator<int>>::const_iterator i = l1.begin(); 638 assert(*i == 1); 639 ++i; 640 assert(*i == 4); 641 ++i; 642 assert(*i == 2); 643 } 644 { 645 std::list<int, min_allocator<int>> l1(a1, a1+2); 646 std::list<int, min_allocator<int>> l2(a2, a2+1); 647 l1.splice(next(l1.begin(), 2), l2); 648 assert(l1.size() == 3); 649 assert(distance(l1.begin(), l1.end()) == 3); 650 assert(l2.size() == 0); 651 assert(distance(l2.begin(), l2.end()) == 0); 652 std::list<int, min_allocator<int>>::const_iterator i = l1.begin(); 653 assert(*i == 1); 654 ++i; 655 assert(*i == 2); 656 ++i; 657 assert(*i == 4); 658 } 659 { 660 std::list<int, min_allocator<int>> l1(a1, a1+2); 661 std::list<int, min_allocator<int>> l2(a2, a2+2); 662 l1.splice(l1.begin(), l2); 663 assert(l1.size() == 4); 664 assert(distance(l1.begin(), l1.end()) == 4); 665 assert(l2.size() == 0); 666 assert(distance(l2.begin(), l2.end()) == 0); 667 std::list<int, min_allocator<int>>::const_iterator i = l1.begin(); 668 assert(*i == 4); 669 ++i; 670 assert(*i == 5); 671 ++i; 672 assert(*i == 1); 673 ++i; 674 assert(*i == 2); 675 } 676 { 677 std::list<int, min_allocator<int>> l1(a1, a1+2); 678 std::list<int, min_allocator<int>> l2(a2, a2+2); 679 l1.splice(next(l1.begin()), l2); 680 assert(l1.size() == 4); 681 assert(distance(l1.begin(), l1.end()) == 4); 682 assert(l2.size() == 0); 683 assert(distance(l2.begin(), l2.end()) == 0); 684 std::list<int, min_allocator<int>>::const_iterator i = l1.begin(); 685 assert(*i == 1); 686 ++i; 687 assert(*i == 4); 688 ++i; 689 assert(*i == 5); 690 ++i; 691 assert(*i == 2); 692 } 693 { 694 std::list<int, min_allocator<int>> l1(a1, a1+2); 695 std::list<int, min_allocator<int>> l2(a2, a2+2); 696 l1.splice(next(l1.begin(), 2), l2); 697 assert(l1.size() == 4); 698 assert(distance(l1.begin(), l1.end()) == 4); 699 assert(l2.size() == 0); 700 assert(distance(l2.begin(), l2.end()) == 0); 701 std::list<int, min_allocator<int>>::const_iterator i = l1.begin(); 702 assert(*i == 1); 703 ++i; 704 assert(*i == 2); 705 ++i; 706 assert(*i == 4); 707 ++i; 708 assert(*i == 5); 709 } 710 { 711 std::list<int, min_allocator<int>> l1(a1, a1+3); 712 std::list<int, min_allocator<int>> l2(a2, a2+3); 713 l1.splice(l1.begin(), l2); 714 assert(l1.size() == 6); 715 assert(distance(l1.begin(), l1.end()) == 6); 716 assert(l2.size() == 0); 717 assert(distance(l2.begin(), l2.end()) == 0); 718 std::list<int, min_allocator<int>>::const_iterator i = l1.begin(); 719 assert(*i == 4); 720 ++i; 721 assert(*i == 5); 722 ++i; 723 assert(*i == 6); 724 ++i; 725 assert(*i == 1); 726 ++i; 727 assert(*i == 2); 728 ++i; 729 assert(*i == 3); 730 } 731 { 732 std::list<int, min_allocator<int>> l1(a1, a1+3); 733 std::list<int, min_allocator<int>> l2(a2, a2+3); 734 l1.splice(next(l1.begin()), l2); 735 assert(l1.size() == 6); 736 assert(distance(l1.begin(), l1.end()) == 6); 737 assert(l2.size() == 0); 738 assert(distance(l2.begin(), l2.end()) == 0); 739 std::list<int, min_allocator<int>>::const_iterator i = l1.begin(); 740 assert(*i == 1); 741 ++i; 742 assert(*i == 4); 743 ++i; 744 assert(*i == 5); 745 ++i; 746 assert(*i == 6); 747 ++i; 748 assert(*i == 2); 749 ++i; 750 assert(*i == 3); 751 } 752 { 753 std::list<int, min_allocator<int>> l1(a1, a1+3); 754 std::list<int, min_allocator<int>> l2(a2, a2+3); 755 l1.splice(next(l1.begin(), 2), l2); 756 assert(l1.size() == 6); 757 assert(distance(l1.begin(), l1.end()) == 6); 758 assert(l2.size() == 0); 759 assert(distance(l2.begin(), l2.end()) == 0); 760 std::list<int, min_allocator<int>>::const_iterator i = l1.begin(); 761 assert(*i == 1); 762 ++i; 763 assert(*i == 2); 764 ++i; 765 assert(*i == 4); 766 ++i; 767 assert(*i == 5); 768 ++i; 769 assert(*i == 6); 770 ++i; 771 assert(*i == 3); 772 } 773 { 774 std::list<int, min_allocator<int>> l1(a1, a1+3); 775 std::list<int, min_allocator<int>> l2(a2, a2+3); 776 l1.splice(next(l1.begin(), 3), l2); 777 assert(l1.size() == 6); 778 assert(distance(l1.begin(), l1.end()) == 6); 779 assert(l2.size() == 0); 780 assert(distance(l2.begin(), l2.end()) == 0); 781 std::list<int, min_allocator<int>>::const_iterator i = l1.begin(); 782 assert(*i == 1); 783 ++i; 784 assert(*i == 2); 785 ++i; 786 assert(*i == 3); 787 ++i; 788 assert(*i == 4); 789 ++i; 790 assert(*i == 5); 791 ++i; 792 assert(*i == 6); 793 } 794 #if _LIBCPP_DEBUG >= 1 795 { 796 std::list<int, min_allocator<int>> v1(3); 797 std::list<int, min_allocator<int>> v2(3); 798 v1.splice(v2.begin(), v2); 799 assert(false); 800 } 801 #endif 802 #endif 803 } 804