Josuttis C++20  C++20 - The Complete Guide: Errata of First Edition

C++20 - The Complete Guide

Errata of the First Edition

September 23, 2023

This is the errata of the 1st printing of the book C++20 - The Complete Guide by Nicolai M. Josuttis.
It covers all errors that were found.

The errata is organized in the following way:
- The first part lists technical errors
- The second part lists typos

Usually the latest electronic version covers all issues of this errata.


Errors

Page 22, 1.6.1 Delegating Free-Standing Comparison Operators: 2022-11-14

The code for the feature test macro is missing:

#ifndef __cpp_impl_three_way_comparison
bool operator==(int i, const MyType& t) {
  return t == i; // OK with C++17
}
#endif

Page 359, 11.3.1, Table 11.1. Standard duration types since C++20: 2023-08-05

The literals d and y yield type std::chrono::day and std::chrono::year , respectively (without s). Thus, they yield a caledrical type rather than a duration type.


Typos

Page 4, 1.1.2 Defining Comparison Operators Since C++20

s/MyType a;/TypeA a;/
s/MyType b;/TypeB a;/

Page 19, 1.5.1 compare_three_way

s/ return std::compare_three_way{}(val<=>v.val); / return std::compare_three_way{}(val, v.val); /

Page 157-159, 6.5.1 Generic Code for Both Containers and Views

s/ const& Does Not Work for All Views / Declaring Range Parameters as const& Does Not Work for Some Views /

s/ // not callable for all views / // not callable for some views /   (4 times)

s/ Non-const && DoesWork for All Views / Declaring Range Parameters as Non-const && /

Page 222, 8.4.1 Iota View, ranges/iotaview.cpp

s/ auto iv3 = std::views::iota(1); // -2 -1 0 1 ... / auto iv3 = std::views::iota(1); // 1 2 3 4 ... /

Page 240, 8.4.6 Span

s/ underlying character sequence / underlying sequence of elements /

Pages 345 and 346, 11.1.1 Scheduling a Meeting on the 5th of Every Month: Other Ways to Initialize Calendrical Types:

s/ auto d1 = std::chrono::years{2021}/1/5; / auto d1 = std::chrono::year{2021}/1/5; /

s/ auto d2 = std::chrono:month{1}/5/2021; / auto d2 = std::chrono::month{1}/5/2021; /

s/ auto d3 = std::chrono:day{5}/1/2021; / auto d3 = std::chrono::day{5}/1/2021; /

s/ auto d5 = 5/1/2021; / auto d5 = 5d/1/2021; /

Page 365, 11.3.5 Time Type hh_mm_ss:

s/ std::chrono::floor<std::chrono:days>(tp) / std::chrono::floor<std::chrono::days>(tp) /

Page 366, 11.3.6 Hours Utilities

s/ std::chrono::make24(h, toPM) / std::chrono::make24(h, isPM) /

Page 631, 19.1 New Types for Non-Type Template Parameters:

s/ or and lvalue reference type / or an lvalue reference type /

 


Home of the C++20 book