Well, I decided to use for_each instead of converting any other solutions:
generator<unsigned int> gen(0, 1); vector<unsigned int> idx(m_nelem);
Where
template<class T> T op_sum (T i, T j) { return i+j; } template<class T> class strMover { T *pP_; T *pMove_; unsigned int stride_; public: strMover(T *pP,T *pMove, unsigned int stride):pP_(pP), pMove_(pMove),stride_(stride) {} void operator() ( const unsigned int ip ) { std::transform(&pP_[ip*stride_], &pP_[ip*stride_]+stride_, pMove_, &pP_[ip*stride_], op_sum<T>); } };
At first glance, it is a stream safe solution.
Arman
source share