|
Boost Users : |
Subject: Re: [Boost-users] for_each_until like algorithm
From: Marshall Clow (marshall_at_[hidden])
Date: 2009-02-11 09:24:56
Robert Jones <robertgbjones_at_[hidden]> wrote:
>On Wed, Feb 11, 2009 at 12:21 PM, Peter Barker
><<mailto:newbarker_at_[hidden]>newbarker_at_[hidden]> wrote:
>
>Sorry for the noise. Just figured std::find_if() should do it.
>
>Hi Peter
>
>Although you've quickly figured out that the functionality you need
>is already there, I
>do agree that the use of find_if() to express until() semantics is
>not immediately
>obvious. I think it is proabably a little "Aha" moment for many of
>us. In a similar
>vein I often find myself writing this functionality
>
>bool exists( begin, end, value )
>{
> return find(begin, end, value) != end;
>}
>
>and
>
>bool exists_if( begin, end, predicate)
>{
> return find_if(begin, end, predicate) != end;
>}
>
>So maybe there is a place for some very thin wrappers.
You might look in the sandbox, specifically in boost/algorithms/all.hpp.
What you call "exists" is called "any" there - which follows the
proposal for TR2.
-- -- Marshall Marshall Clow Idio Software <mailto:marshall_at_[hidden]> It is by caffeine alone I set my mind in motion. It is by the beans of Java that thoughts acquire speed, the hands acquire shaking, the shaking becomes a warning. It is by caffeine alone I set my mind in motion.
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net