| 14 | } |
| 15 | |
| 16 | int main() |
| 17 | { |
| 18 | const size_t boxCount {20}; // Number of Box object to be created |
| 19 | |
| 20 | // Create boxCount Box objects |
| 21 | Truckload load; |
| 22 | for (size_t i {}; i < boxCount; ++i) |
| 23 | load.addBox(randomSharedBox()); |
| 24 | |
| 25 | DeliveryTruck truck{ load }; // Copy the load, because we still need it below. |
| 26 | // Note that all Boxes are shared, so the they themselves are not copied. |
| 27 | |
| 28 | // Register two callback functions: |
| 29 | truck.registerOnDelivered(logDelivary); |
| 30 | |
| 31 | unsigned count {}; |
| 32 | truck.registerOnDelivered([&count](SharedBox) { ++count; }); |
| 33 | |
| 34 | // Deliver some boxes: |
| 35 | for (size_t i : { 5u, 8u, 11u }) |
| 36 | truck.deliverBox(load[i]); |
| 37 | |
| 38 | std::cout << count << " boxes were delivered. On time, as always!" << std::endl; |
| 39 | } |
nothing calls this directly
no test coverage detected