
19 Dec
2024
19 Dec
'24
3:30 p.m.
The case against a free function gets a lot stronger once you remember that optional in C++ still supports unchecked accesses with trivial syntax and that the most ergonomic and safe way to actually use it is via something like this: users.find(user_id).map([](auto& user) { user.status = deactivated; return user; }); Were this a free function, a user wouldn't be able to create this nice fluent interface that users, by and large, seem to actually like. - Christian