Boost logo

Boost Users :

Subject: Re: [Boost-users] Do "entire range" standard algorithms already exist
From: Marshall Clow (marshall_at_[hidden])
Date: 2009-01-31 13:26:33


>Content-class: urn:content-classes:message
>Content-Type: multipart/alternative;
> boundary="----_=_NextPart_001_01C98363.78536B2F"
>
>Group,
>I recently found the boost::range library. It seems very useful.
>An annoyance that I have with STL algorithms is that they are very
>verbose. Most of the time I need to do something over the entire
>range. I'm sure I'm not alone here.
>
>At any rate, I can easily do this:
>
>template< typename Range, typename Pred >
>inline typename boost::range_iterator<Range>::type
>find_if( Range& c, Pred pred )
>{
> return std::find_if( boost::begin( c ), boost::end( c ), pred );
>}
>
>Which then allows me to do this:
>
>void foo()
>{
> typedef std::vector <int> V_INT;
> V_INT v;
> v.push_back(1);
> v.push_back(2);
> v.push_back(3);
>
> V_INT::iterator it = find_if(v, std::bind2nd(std::equal_to<int>(), 2));
>}
>
>Perfect. Exactly what I want. Search the entire vector, and I give
>it a predicate.
>
>I could easily create these functions for copy_if, erase_if,
>find_if, and for_each.
>
>My question:
>Do I need to go ahead and create the tiny wrapper functions, or do
>they already exist somewhere in Boost? If they exist already, I
>prefer to use those.

Some exist in the sandbox.
        Look in sandbox/boost/algorithm.

-- 
-- 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