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/when it comes
to std::optional 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
.
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.
There is s a short example on godbolt 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.
regards,
Ivan