|
Boost : |
Subject: [boost] for_each abstraction
From: Karsten Ahnert (karsten.ahnert_at_[hidden])
Date: 2010-11-17 11:22:36
Hi,
I need something like an abstraction layer for iterations over some
range. Consider for example the following three statements, which all do
the same, but the loop inside each for_each is different:
// thrust is an STL-like interface for CUDA [1]
thrust::device_vector< double > a1( 3 );
thrust::for_each( a1.begin() , a1.end() , op() );
std::vector< double > a2( 3 );
__gnu_parallel::for_each( a2.begin() , a2.end() , op() );
std::vector< double > a3( 3 );
std::for_each( a3.begin() , a3.end() , op() );
//maybe even
fusion::vector< double , double , double > a4;
fusion::for_each( a4 , op() );
Is there a way or some part of a boost-library which handles the above
three statements in a unique manner? I want to write algorithms which
are independent of the specific for_each implementation.
Best regards,
Karsten
[1] http://code.google.com/p/thrust/
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk