Enough with the toy examples, though. Remember our Dominican Fair application from Chapter 3, Functional and Nonfunctional Requirements? Let's write a component that will select and display a few featured items from the stores that a customer saved as their favorites. This can be pretty handy when we're writing a mobile app, for example.
Let's start with a mostly C++17 implementation, which we'll update to C++20 throughout this chapter. This will include adding support for ranges.
First, let's start with some code for obtaining information about the current user:
using CustomerId = int; CustomerId get_current_customer_id() { return 42; }
Now, let's add the store owners:
struct Merchant { int id; };
The stores also need to have items in them:
struct Item { std::string name; std::optional<std::string> photo_url; std::string description; std::optional<float> price; time_point<system_clock> date_added...