Skip to content

C++ — a learning library

Learn C++ one runnable page at a time. Every claim on every page is backed by a program that compiles, runs, and prints what the page says — and it has to print it on two standard libraries: libstdc++ (GCC, on Ubuntu) and libc++ (Apple clang, on macOS). CI holds both runs to one recorded answer key, so what a page shows is what the C++ standard promises, not what one vendor happened to do.

Where the libraries genuinely differ — in the first chapter they disagree about which clock high_resolution_clock even is — the page says so in a dated table that names the compiler, the library and the machine. That table is the only place a platform-specific number is allowed.

Start here

Start here — what the library assumes, how to compile one example yourself, and the three kinds of evidence a page can show you.

The chapters

Chapter What it covers
01 Time and benchmarking std::chrono's three clocks, the types they hand you, and why the first honest benchmark is harder than it looks — following Matt Godbolt's C++Now 2026 keynote

What comes next is on the roadmap; what the pages cite is in the resources.

Running the examples

You need a C++20 compiler and nothing else — no CMake, no package manager, no benchmark framework. Every example is one file:

c++ -std=c++20 -O2 01_Time_and_Benchmarking/three_clocks/examples/three_clocks.cpp -o three_clocks && ./three_clocks

To compile, run and check every example against its recorded output:

python3 tools/run_examples.py --check

The one rule

No page hand-types what a program prints. A lesson marks the spot and the runner fills it from a real run — so an example that behaves differently on a new compiler breaks the build instead of quietly making a page wrong. See CONTRIBUTING.md.

Sibling libraries

Same format, same answer-key contract: