Boost logo

Boost :

From: Pavol Droba (droba_at_[hidden])
Date: 2005-11-28 16:41:51


On Mon, Nov 28, 2005 at 09:00:53PM +0000, Martin wrote:
> > Sorry for keeping you waiting. I have not forgotten about it and
> > I would very much like to put it to the next release.
> >
> > I just haven't find a time to look into But I have it in my schedule
> > before xmas.
>
> Any chance we'll see _real_ predicates as well (i.e. starts_with etc that can
> be used with standard algorithms)?
>
> std::find_if(v.begin(), v.end(), istarts_with("abcd"));
>

What you have shown is just a simple example of currying and there are at least
two facilities in Boost that provide such a functionality. Namely Boost.Bind and
Boost.Lambda.

You can write something like this:

std::find_if(
      vec.begin(),
      vec.end(),
      boost::bind<bool>(boost::istarts_with<std::string, std::string>, _1, "bc", std::locale()));

It is not as nice as your example, but it works.

I'm little bit reluctant to add something like this directly to the library.
There are already quite a lot of variants of algorithms. Adding some more
could be quite confusing. I would prefere to add some realy new functionality.

But don't take this as a final 'no' from me. I'm open for discussion.

Best regards,
Pavol


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