read

It does not matter how often one proofreads the book, there will be always bugs in the code or some issues. We will document the issues here and update the code on GitHub. Of course, we will update the potential new release of the book accordingly.

Chapter 3

Listing 3.3 the cases for even and odd are wrong in the code and should be chnaged to

if (values.size() % 2 == 0) {
  median = *mid; |\label{container:median:list:defref}|
}  else {
  auto mid_one = values.begin();
  std::advance(mid_one, mid_index + 1);
  median = 0.5 * (*mid + *mid_one);
} 

Listing 3.6 the C++20 range-based for statements with initializer

for (int index = 0; const int value : values) {
std::cout << "Index=" << index++ << " Value= " << value
}

Chapter 15

Listing 15.7 on page 175 of the printed version the lines 38 to 40 should be removed.

38 std::vector<hpx::future<void>> futures;
39 
40 hpx::when_all(futures).get();

Appendix

Listing A.10 is correct in source file, however, the pipes used for the ranges are not correctly rendered in the book.

#include <cmath>
#include <iostream>
#include <ranges>
#include <vector>

int main() {
  std ::vector<int> values = {0, 1, 2, 3, 4, 5, 6};

  auto tr_values = values
    |  std::views::filter([](int value) { return value % 2 == 0; }) 
    |  std::views::transform([](int value) -> double { return std::sqrt(value);});
  for (int i : tr_values)
      std::cout << double(i) << ' ';
  std::cout << std::endl;
}
Blog Logo

The authors


Published