4 ms·
I've been using ranges fairly often but it's only for stuff like this: auto it = std::ranges::find(ctx.users, req_user_id, &User::user_id); If ctx.users i
by mpyne 1y ago
I've been using ranges fairly often but it's only for stuff like this:
auto it = std::ranges::find(ctx.users, req_user_id, &User::user_id);
If ctx.users is a vector<Users>, it will return an iterator pointing to the first matching User, by matching a field in User to a variable.
It's just syntax sugar for std::find and a simple lambda but it's been really nice syntax sugar.