
17 Nov
2010
17 Nov
'10
9:44 p.m.
// 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.