Boost logo

Boost :

Subject: Re: [boost] for_each abstraction
From: Karsten Ahnert (karsten.ahnert_at_[hidden])
Date: 2010-11-17 16:44:59


>> // the complex algorithm we want to implement
>> template< class Algorithm , class Sequence>
>> void do_something( Sequence&seq )
>> {
>> ...
>> Algebra::for_each( seq , op() );
>
> ^^^^^^^
> Algorithm
>
>> ...
>> }

Yes right, thanks.

> std::vector< double > vec1;
> vec1.for_each(op());
> thrust::device_vector< double > vec2;
> vec2.for_each(op());

Yes, it might by possible to bind for_each to a specific container.
But, it would also be nice to have an additional degree of freedom in
the way how things are iterated. Think for example on something like

template< class Seq1 , class Seq2 , class BinarayOp
for_each( Seq1 &seq1 , Seq2 &seq2 , BinaryOp op ) { }

which could be implemented directly by iteration of both sequences or by
use zip_iterators.


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