Subject: Re: [boost] std::map::find() wrapper
From: Christian Holmquist (c.holmquist_at_[hidden])
Date: 2011-06-02 14:52:11
On 2 June 2011 12:57, Denis Shevchenko <for.dshevchenko_at_[hidden]> wrote:
> What's the best way to get this wrapper into Boost?
>>>> Somebody? Please?
> Olaf, the point is not that the library is useful for YOU, but rather
> whether it useful for OTHERS programmers. This is the criterion for
> inclusion library in the Boost.
> - Denis
We've a function like this among our quite extensive set of useful stl
While I agree this one is useful, I think most organizations are better off
collecting their own set of utilities that suits their common use cases
Writing a std::map::find wrapper that aim to suit everyone is opening a can
of worms, IMHO.
Personally, I'd like to see a 'Boost.Algorithm.Find' package, that short and
concisely can capture the myriads of different ways to express find, and
that works on associative and sequence containers of tuples.
Maybe something like this.
std::vector<std::pair<int, float> > v;
std::map<int, float> m;
boost::algorithm::find_optional<0>(m, 3) -> map::find(...)
boost::algorithm::find_optional<1>(m, 3.0) -> std::find(...)
The compile time constant indicates which tuple element to find (fusion
Return value is always optional<Container::value_type&>. (and const versions
The algorithm is responsible for using the best implementation of find, i.e.
avoid going trough std::find() if the container is associative and the
element index is 0.
If element index is 1, it needs to use std::find also for
associative, Unless it's boost::bimap.. =)
Probably not worth the effort.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk