Boost logo

Boost :

From: Vinnie Falco (vinnie.falco_at_[hidden])
Date: 2024-12-19 18:46:05


On Thu, Dec 19, 2024 at 10:06 AM Peter Dimov via Boost <
boost_at_[hidden]> wrote:

> Vinnie Falco wrote:
> > On Thu, Dec 19, 2024 at 7:30 AM Christian Mazakas via Boost <
> > boost_at_[hidden]> wrote:
> >
> > > users.find(user_id).map([](auto& user) { user.status =
> > > deactivated; return user; });
> > >
> >
> > try_find( users, user_id ).map(
> > [](auto& user)
> > {
> > user.status = deactivated;
> > return user;
> > });
>
> In what namespace and in what header is try_find defined?
>

Haven't thought about this and here's a guess:

    #include <boost/try_find.hpp>
    ...
        boost::try_find( users, user_id ).map(
            [](auto& user)
            {
                user.status = deactivated;
                return user;
            });

In this case `try_find` would return `boost::optional`. And
`std::try_find` could return `std::optional`.

Thanks


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk