Intel® oneAPI Threading Building Blocks
Ask questions and share information about adding parallelism to your applications when using this threading library.
Announcements
The Intel sign-in experience has changed to support enhanced security controls. If you sign in, click here for more information.
2452 Discussions

Difference between normal for and range based for loop?

Riyad_Parvez
Beginner
210 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