ccia_code_samples icon indicating copy to clipboard operation
ccia_code_samples copied to clipboard

Listing 8.3 - Compiler Error

Open ITHelpDec opened this issue 1 year ago • 0 comments

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... https://github.com/anthonywilliams/ccia_code_samples/blob/6e7ae1d66dbd2e8f1ad18a5cf5c6d25a37b92388/listings/listing_8.3.cpp#L50-L51 ... with a range-based for loop.

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

Tested successfully on gcc, clang and apple clang.

ITHelpDec avatar Jun 16 '23 22:06 ITHelpDec