Boost logo

Boost :

From: Ivan Matek (libbooze_at_[hidden])
Date: 2024-12-16 14:54:02


On Mon, Dec 16, 2024 at 3:20 PM Rainer Deyke via Boost <
boost_at_[hidden]> wrote:

>
> I'd much rather have this as a generic free function than as a member
> function. That way it works on all associative containers, not just the
> ones supplied by Boost.
>
>
> That suffers from not being left to right code, e.g. we have
basic_string::starts_with, not free function starts_with(str, ...).
But if you want a free function that can easily be implemented by you.
I would just advise you to be careful about semantics/what containers it
accepts.
Usually STL convention is that free function works, but member functions
are there if they are faster, e.g. find algorithm vs find member function
that has better complexity.
So free function dispatching to member function might be confusing.

For people like me that prefer member function we have no choice but to ask
boost authors for approval since in general inheriting from boost container
and giving it some other name just to add one member function is quite a
bit overhead in code, not to mention that it is not really nice to do that
because there are no virtual destructors in boost containers(for
performance reasons).


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