Boost logo

Boost :

From: vicente.botet (vicente.botet_at_[hidden])
Date: 2008-07-22 00:55:27


----- Original Message -----
From: "Robert Jones" <robertgbjones_at_[hidden]>
To: <boost_at_[hidden]>
Sent: Monday, July 21, 2008 11:07 PM
Subject: Re: [boost] [lambda] Writing pass-through 'standard' algorithms

>
> On Mon, Jul 21, 2008 at 9:55 PM, vicente.botet <vicente.botet_at_[hidden]>
> wrote:
>
>> What exactly do not compiles? I have not founf ptr_fun on your function.
>> If predicate is a predicate functor this should compile, isn't it? The
>> following compiles:
<snip>
>
> Sorry, I'm not explaining myself too well. Yes your example compiles,
> provided the predicate
> is an adaptable functor (typedefs argument_type). If the predicate is a
> raw
> function then
> the ptr_fun adaptor is required, but that will ONLY work for a raw
> pointer.
> My difficulty
> is in finding a direct solution that works for all cases.

Hi,

all cases are a lot of cases. Please could you be more explicit on the cases
you want to cover.

Are you thinking on boost::function<bool(typename
InputIterator::value_type)>. What about?

template <typename InputIterator, typename Predicate >
inline bool all_if(InputIterator first, InputIterator last, Predicate pred)
{
    boost::function<bool(typename InputIterator::value_type)>
predicate=pred;
    return std::find_if(first, last, std::not1( predicate ) ) == last;
}

Vicente


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