| 653 | // Inserts values via move and verifies no copies occurred on the hot path. |
| 654 | template<typename Map> |
| 655 | void test_map_move_semantics() { |
| 656 | Map m; |
| 657 | |
| 658 | // Insert via move-constructed pair |
| 659 | MoveTrackItem item1(42); |
| 660 | int initial_move_count = item1.move_count; |
| 661 | m.insert(fl::pair<int, MoveTrackItem>(1, fl::move(item1))); |
| 662 | FL_CHECK(item1.move_count > initial_move_count); |
| 663 | FL_CHECK(m.size() == 1); |
| 664 | |
| 665 | // Insert another |
| 666 | m.insert(fl::pair<int, MoveTrackItem>(2, MoveTrackItem(99))); |
| 667 | FL_CHECK(m.size() == 2); |
| 668 | |
| 669 | // Find and verify values were moved, not copied |
| 670 | auto it1 = m.find(1); |
| 671 | FL_CHECK(it1 != m.end()); |
| 672 | FL_CHECK(it1->second.value == 42); |
| 673 | FL_CHECK(it1->second.copy_count == 0); |
| 674 | |
| 675 | auto it2 = m.find(2); |
| 676 | FL_CHECK(it2 != m.end()); |
| 677 | FL_CHECK(it2->second.value == 99); |
| 678 | FL_CHECK(it2->second.copy_count == 0); |
| 679 | |
| 680 | // Erase and verify |
| 681 | m.erase(1); |
| 682 | FL_CHECK(m.size() == 1); |
| 683 | FL_CHECK(m.find(1) == m.end()); |
| 684 | } |
| 685 | |
| 686 | // ============================================================================ |
| 687 | // PATTERN 2: CONCRETE CONTAINER TYPE (Specific Element Types) |