3 Apr
2022
3 Apr
'22
11:55 p.m.
On 4/4/22 01:58, Marshall Clow via Boost wrote:
On Apr 3, 2022, at 3:09 PM, Viktor Sehr
mailto:viktor.sehr@gmail.com> wrote: Why not return a pointer/nullptr instead? pfind_if
Why not just check to see if the returned iterator == end () ?
Exactly. The iterator has the added benefit that it can be used with the container to perform further operations (e.g. remove the element). The only benefit of pointer/optional is that is allows to decouple the element from the container (e.g. if you want to hide the container type from the caller), and this can be achieved with a trivial wrapper function.