10 #ifndef META_PARALLEL_FOR_H_
11 #define META_PARALLEL_FOR_H_
31 template <
class Iterator,
class Function>
45 template <
class Iterator,
class Function>
49 auto block_size = std::distance(begin, end)
50 / std::thread::hardware_concurrency();
52 Iterator last = begin;
56 (std::thread::hardware_concurrency() - 1) * block_size);
64 std::vector<std::future<void>> futures;
66 for (; begin != last; std::advance(begin, block_size))
71 std::advance(mylast, block_size);
72 std::for_each(begin, mylast, func);
77 { std::for_each(begin, end, func); }));
78 for (
auto& fut : futures)