Boost logo

Boost :

From: Marshall Clow (mclow.lists_at_[hidden])
Date: 2022-04-03 22:58:57


On Apr 3, 2022, at 3:09 PM, Viktor Sehr <viktor.sehr_at_[hidden] <mailto:viktor.sehr_at_[hidden]>> wrote:
>
> Why not return a pointer/nullptr instead? pfind_if

Why not just check to see if the returned iterator == end () ?

— Marshall

>
> Den sön 3 apr. 2022 21:46Marshall Clow via Boost <boost_at_[hidden] <mailto:boost_at_[hidden]>> skrev:
> On Mar 22, 2022, at 2:09 PM, Ivan Matek via Boost <boost_at_[hidden] <mailto:boost_at_[hidden]>> wrote:
> >
> > Hi,
> > I have been thinking for this for a long time so I wanted to get the
> > feedback from others.
> >
> > As you probably know better than me there is a bit of a drama
> > <https://brevzin.github.io/c++/2021/12/13/optional-ref-ptr/ <https://brevzin.github.io/c++/2021/12/13/optional-ref-ptr/>>when it comes
> > to std::optional<T&> and from what I see it will not be in C++23 for sure.
> > I believe this gives an opportunity to boost to provide something nice for
> > the users.
> >
> > Now the issues are the following:
> > AFAIK boost only has old ranges and iterator based algorithms, ideally we
> > would just have something like std:: ranges and add the ofind/ofind_if to
> > those, but AFAIK those do not exist.
> > So I think best thing would be to add it to boost::algorithm
> > <https://github.com/boostorg/algorithm/tree/develop/include/boost/algorithm <https://github.com/boostorg/algorithm/tree/develop/include/boost/algorithm>>
> > .
> > There are further questions like, should boost containers like
> > map/unordered_map gain similar functionality, but I think deciding if we
> > want the general algorithm is the first step.
> >
> > Another option I can think of is that those algorithms return something
> > like a 0 or 1 element view(so you could access the optional value with
> > range based for loop). This seems weird to me, so I would prefer
> > boost::optional<T&>.
> >
> > There is s a short example on godbolt <https://godbolt.org/z/W9K3na9Gc <https://godbolt.org/z/W9K3na9Gc>>,
> > but don't look at implementation too much, it was just something I hacked
> > quickly, I am mostly interested in in feedback on if functionality would be
> > nice addition to boost.
>
> Personally, I’m not really that enthusiastic about this interface.
> However, if someone wants to make a PR for boost.Algorithm, I will certainly review it.
>
> — Marshall
>
>
>
> _______________________________________________
> Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost <http://lists.boost.org/mailman/listinfo.cgi/boost>


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