Iteration through std containers in openmp

Posted by Sasun Hambardzumyan on Stack Overflow See other posts from Stack Overflow or by Sasun Hambardzumyan
Published on 2010-03-25T08:34:12Z Indexed on 2010/03/25 13:53 UTC
Read the original article Hit count: 683

Filed under:
|
|

Hi, people. I try to use openmp for multithreading the loop through std::set. When I write the following code -

    #pragma omp parallel for
    for (std::set<A>::const_iterator i = s.begin(); i != s.end(); ++i) {
            const A a = *i;
            operate(a);
    }

I get an error - error: invalid type for iteration variable 'i' error: invalid controlling predicate error: invalid increment expression.

So is there an another way to correct iteration in std containers using openmp? There is a workaround to use int i and iterate from 0 to s.size() and using iterator inside a loop body, but this is not looks good.

© Stack Overflow or respective owner

Related posts about c++

Related posts about stl