Parallel Random Access Iterator Loop
3.16. Parallel Random Access Iterator Loop#
The following example shows a parallel random access iterator loop.
//%compiler: clang
//%cflags: -fopenmp
/*
* name: pra_iterator.1
* type: C++
* version: omp_3.0
*/
#include <vector>
void iterator_example()
{
std::vector<int> vec(23);
std::vector<int>::iterator it;
#pragma omp parallel for default(none) shared(vec)
for (it = vec.begin(); it < vec.end(); it++)
{
// do work with *it //
}
}