Skip to content

Conversation

@ITHelpDec
Copy link

Issues

  1. Two headers are missing (<numeric> and <functional>)
  2. Our std::packaged_task is constructed incorrectly (requires extra parentheses)
  3. The default constructor for accumulate_block is mistakenly called in place of accumulate_block<Iterator,T>::operator()

Stylistically it might also be nice to replace lines 50-51...

std::for_each(threads.begin(),threads.end(),
std::mem_fn(&std::thread::join));

... with a range-based for loop.

for (auto &t : threads) { t.join(); }

Tested successfully on gcc, clang and apple clang.

Two headers needed for compilation on gcc and clang

+ #include <numeric>    // std::accumulate
+ #include <functional> // std::mem_fn

(Apple Clang only needs <numeric>)
"Parentheses were disambiguated as a function declaration"
- extra parentheses needed to call `accumulate_block<Iterator,T>::operator()` in place of default constructor

"No matching constructor for initialization of 'accumulate_block<std::__wrap_iter<int *>, int>'"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant