C++20/23 and capstone projects
This part of the C++ course is the newest language and then three programs built with it. Modules replace the header, a history lesson puts every standard side by side, and the C++20 and C++23 lessons list what each one added. Legacy code is read and modernised, and C and C++ solve one task side by side. The rest is the capstones: a JSON parser with a writer and tests, a task tracker with a file format and a command line, and an inverted index that is measured and made faster.
12.1
C++20 modules
export module, import, the gcm.cache that g++ writes and a module built with -fmodules-ts
Open
12.2
C++98 to C++23 in one file
__cplusplus under each -std value, and a feature that each standard added
Open
12.3
C++20 features
designated initialisers, the spaceship operator, std::span, bit operations and consteval
Open
12.4
C++23 features
std::expected, std::print, std::flat_map, deducing this and multidimensional subscript
Open
12.5
Reading legacy C++
C-style arrays and casts, malloc in C++, and a class modernised step by step
Open
12.6
C++ and C side by side
the same task in C and in C++, and what the C++ version moves to the compiler and the library
Open
12.7
Capstone 1: a JSON tokenizer
the project layout, the token type and a lexer that walks a JSON document
Open
12.8
Capstone 1: the parser
a recursive descent parser, the value type it builds and the errors it reports
Open
12.9
Capstone 1: a JSON value
a variant of object, array, string, number, bool and null, with accessors and printing
Open
12.10
Capstone 1: writing JSON
escape strings, indent nested values and round-trip the document
Open
12.11
Capstone 1: testing the parser
a table of good and bad documents, a test runner and the bugs it finds
Open
12.12
Capstone 2: a task model
a task with an id, a state and a due date, and the operations that keep it valid
Open
12.13
Capstone 2: saving tasks
a line-based file format, load and save, and a corrupt line that is skipped
Open
12.14
Capstone 2: the command line
parse subcommands, dispatch to handlers and print a task list
Open
12.15
Capstone 2: error handling
std::expected through the layers, error messages for the user and a non-zero exit code
Open
12.16
Capstone 2: testing the tracker
test the model, the storage and the commands, with a temporary file per test
Open
12.17
Capstone 3: a tokenizer
split documents into words, normalise case and keep the positions
Open
12.18
Capstone 3: the inverted index
map a word to the documents and positions that hold it, and build it from a directory
Open
12.19
Capstone 3: queries and ranking
AND and OR queries, a ranked answer and a phrase search over positions
Open
12.20
Capstone 3: measure and speed it up
time the index build and the queries, then improve the hot path and measure again
Open