All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
tbb_pfor_01_t.cc
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 // tbb_pfor_01_t
3 //
4 // Demonstrate trivial use of blocked_range and parallel_for over a
5 // vector.
6 //
7 ////////////////////////////////////////////////////////////////////////
8 #include "tbb/tbb.h"
9 
10 #include <iostream>
11 
12 int
14 {
15  size_t const n = 500000;
16  std::vector<double> v(n, 27.64), vr;
17  vr.reserve(n);
19  tbb::parallel_for(br_t(v.cbegin(), v.cend()), [&vr](br_t const& r) -> void {
20  for (auto i : r) {
21  vr.emplace_back(i * 2.0);
22  }
23  });
24  std::cout << vr.back() << std::endl;
25 }
tbb::blocked_range< typename std::vector< double >::const_iterator > br_t
intermediate_table::const_iterator const_iterator
int main()