| 591 | // Front and back element access for map containers |
| 592 | template<typename Map> |
| 593 | void test_map_front_back() { |
| 594 | Map m; |
| 595 | m.insert(fl::make_pair(1, 100)); |
| 596 | m.insert(fl::make_pair(2, 200)); |
| 597 | m.insert(fl::make_pair(3, 300)); |
| 598 | |
| 599 | // For sorted maps (flat_map, map), elements are ordered by key |
| 600 | // front() should give the element with smallest key |
| 601 | // back() should give the element with largest key |
| 602 | auto front_pair = m.front(); |
| 603 | auto back_pair = m.back(); |
| 604 | |
| 605 | FL_CHECK(front_pair.first == 1); |
| 606 | FL_CHECK(front_pair.second == 100); |
| 607 | FL_CHECK(back_pair.first == 3); |
| 608 | FL_CHECK(back_pair.second == 300); |
| 609 | } |
| 610 | |
| 611 | // Move-tracking item that allows copies but tracks them. |
| 612 | // Unlike TestItem (which deletes copies), this type lets us verify that |