|
Boost : |
From: Peter Dimov (pdimov_at_[hidden])
Date: 2001-02-28 07:24:21
From: <yahoo_at_[hidden]>
> --- In boost_at_y..., Gary Powell <Gary.Powell_at_s...> wrote:
> > Well if your compiler has partial specialization, lambda does this
> very
> > nicely.
> >
> > std::for_each(c.begin(), c.end(),
> ll::for_each(free1->(&CType::begin),
> >
> free1->(&CType::end),
> > _Fn);
> >
> > Where _Fn can be another Lambda statement or a functor.
> > -gary-
>
> As much as I enjoy LL (I demand LL support to even consider using a
> compiler !), I think it's more a job for an iterator adaptor
> based on a pair<OuterContainerIterator, InnerContainerIterator>
> ( I've hastly crafted some ugly code to do that),
> but maybe a deep_view would be even better :-)
Yep, I'm a big fan of lambda-type libraries as well, but in this case I'd
rather do
void apply_fn(CType & t)
{
std::for_each(t.begin(), t.end(), Fn);
}
std::for_each(c.begin(), c.end(), apply_fn);
-- Peter Dimov Multi Media Ltd.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk