Intel® oneAPI Threading Building Blocks
Ask questions and share information about adding parallelism to your applications when using this threading library.
2466 Discussions

Difference between normal for and range based for loop?

Riyad_Parvez
Beginner
384 Views

What is the difference between these two loop? 

tbb::concurrent_vector<T> list;
tbb::parallel_for(tbb::blocked_range<size_t>(0, list.size()),
    [&](const tbb::blocked_range<size_t>& r)
    {
        for(size_t i = std::begin(r); i != std::end(r); ++i)
        {
            //Do something with list
        }
    }
);

tbb::parallel_for(tbb::blocked_range<size_t>(0, list.size()),
    [&](const tbb::blocked_range<size_t>& r)
    {
        for(auto& l : list)
        {
            //Do something with l
        }
    }
);

0 Kudos
0 Replies
Reply