A hands-on reference for learning modern C++ — the language and the standard library, from C++11 through the latest standard (C++26) — organized as bite-sized, example-driven Markdown notes, plus opinionated guidelines on how to write C++ well.
The reference mirrors how cppreference.com organizes C++. Facts can come from any good source — cppreference, the standard draft, WG21 papers, compiler and library docs — as long as they've been verified locally (the snippet compiles, and behaves as described when run).
Full platform / compiler / architecture support →
Everything is clickable. The reference lives in
docs/examples/ (master index and progress); each
area has its own README.
- Containers — vector, map, span, the lot
- adaptors: std::flat_map / std::flat_multimap · std::flat_set / std::flat_multiset · std::priority_queue · std::queue · std::stack
- associative: std::map · std::multimap · std::multiset · std::set
- sequence: std::array · std::deque · std::forward_list · std::hive · std::inplace_vector · std::list · std::vector
- unordered: std::unordered_map · std::unordered_multimap · std::unordered_multiset · std::unordered_set
- views: std::mdspan · std::span
- Strings —
string,string_view, char traits - Text processing —
format/print,charconv, regex, locales,text_encoding, C strings - Algorithms —
<algorithm>,<numeric>, parallel & ranges algos - Ranges — views, adaptors, factories, pipelines (C++20)
- Iterators — categories, adaptors,
iterator_traits - Utilities —
optional,variant,tuple,expected, function objects, callable wrappers (function_ref…) - Memory — smart pointers,
indirect/polymorphic, allocators, memory resources - Metaprogramming —
type_traits, constant evaluation, reflection (<meta>),ratio,integer_sequence - Numerics —
random,complex,<cmath>,<cfenv>,<bit>, saturation arithmetic, SIMD, linalg - Date & time —
<chrono>: durations, clocks, calendars, time zones;<ctime> - Input/output — streams, files, string streams, filesystem,
syncstream,print - Concurrency — threads, mutexes, atomics, futures, RCU & hazard pointers
- Execution — senders/receivers (C++26)
- Diagnostics — exceptions,
system_error,stacktrace,<debugging> - Language support —
numeric_limits,<=>,source_location,initializer_list,typeid, signals,setjmp - Concepts — the standard concepts library (C++20)
- Feature-test macros — detecting what your compiler supports
- Named requirements — CopyConstructible, Compare, Hash … and how concepts relate
- Basic concepts — comments, keywords, types, names/lookup, storage/linkage, object lifetime, erroneous behaviour,
main, freestanding - Expressions — value categories, operators, conversions, literals, constant exprs
- Statements —
if/switch, loops, range-for,break/continue/return/goto - Declarations & initialization —
auto,const/constexpr, the many initializations - Functions — overloading, default args, lambdas
- Classes — special members, RAII, inheritance, virtual, unions, deducing
this, bit-fields, operator overloading - Templates — function/class templates, variadics, CTAD, constraints & concepts
- Exceptions —
throw/try/catch,noexcept, exception safety - Coroutines —
co_await/co_yield/co_return(C++20) - Modules —
import/export, partitions,import std;, building with GCC/Clang/CMake (C++20) - Preprocessor — macros, includes, conditional compilation,
#embed
docs/guidelines/— how to use it well (see Guidelines)docs/security/— how to write C++ that holds up against an attacker: trust boundaries, untrusted input, secrets, hardening, verification, supply chain, deployment and policy, every page verified against primary sources and our compilers, with tests intests/security/(v0.5.0, #286)fuzz/— libFuzzer targets for the security pages' parsers, with a saved corpus replayed as teststests/— GoogleTest suite that checks the pages' claims (see Testing and CI)tools/check_snippets.py— compile-checks every```cppblock (snippet_prelude.hpp,snippet_baseline/);tools/run_tests.sh(orrun_tests.ps1on Windows) runs the tests,tools/ctest_to_json.pywrites their results as JSONdocs/testing.md— how the snippets and tests are checked, the toolchain presets and the manual CI workflowsdocs/platform-support.md— platforms, compilers and architectures the tests and snippets have run on (local runs and consented GitHub Actions runs), with the known gaps per toolchain; generated bytools/collect_results.pyevals/— test cases for thecpp-guidelinesagent skill.claude/skills/—cpp-guidelines(review against the Core Guidelines),refresh-guidelines(keep them current),add-to-topic(add a feature or gotcha to the reference),modern-cpp(start here: write C++ using this reference),cpp-security(security review, hardening and verification),platform-support(run, read and report the platform runs)modules/— submodules: C++ Core Guidelines, perf-report
Every area on cppreference's main page has pages, and every snippet compiles (or is tagged with why it can't). A GoogleTest suite that checks each page's claims at run time is in progress: #41.
The reference tells you what each feature is;
docs/guidelines/ tells you how to use it well:
- C++ Core Guidelines — every official rule, by section, linked to the official text · worked examples
- Memory & safety — profiles, ownership, dangling, C++26 hardening
- Modern idioms — C++17 → C++26 and when to reach for each
- Design principles — Ben Deane's composable, hard-to-misuse style
- Project conventions — naming, headers, API shape, tests
- Industry practice — Google/Chromium/LLVM policies, Abseil tips, the GSL
- Tooling — sanitizers, suppressions, hardened libraries, static analysis
- Debugging — gdb and lldb side by side, core dumps,
std::stacktrace - Valgrind — Memcheck, Helgrind and DRD, suppressions, vgdb
- Performance tooling — benchmarking,
perf, flame graphs, heap profiling - Testing — frameworks, property-based tests, fuzzing, contracts, coverage
- Build and packaging — CMake, presets, modules, dependencies, flags
Sources and edition dates are in sources.md. To
refresh them or import a new reference, ask Claude to use the
refresh-guidelines skill.
The modern-cpp skill makes Claude Code
check this reference before writing C++. It:
- looks up the page for a facility and follows its gotchas and version notes;
- checks that the feature is supported on every compiler you build with, against this repo's measured results on about 50 toolchains;
- applies the guidelines and validates the result.
Start with /modern-cpp. It's the preferred entry point for writing,
modernizing or reviewing C++, and it calls /cpp-guidelines itself when the
guidelines matter. Use /cpp-guidelines directly only for:
- Reviewing or auditing existing code against the Core Guidelines, where you want findings with rule IDs (R.11, C.13) and no new code.
- A question about a specific rule ("what does F.16 say, and does this code follow it?") or about one guidelines page.
- A focused ownership, lifetime or memory-safety fix in code that already uses the right facilities.
- Measuring the guidelines skill with the case suite in
evals/(31 cases across ownership, classes, expressions, concurrency and errors; it also has a suite formodern-cpp).
For security, use /cpp-security. It reviews code where an attacker
controls part of the input (trust boundaries, sizes and bounds, parsing,
secrets, fail-closed errors), hardens a build for your actual compiler and
standard library, and plans the security tests, citing
docs/security/, Core Guidelines and SEI CERT
rule IDs.
Install it once for all your projects: clone this repo and run
make install. That links modern-cpp,
cpp-guidelines (review C++ against
the Core Guidelines, citing rule IDs) and
cpp-security into ~/.claude/skills.
git clone https://github.com/homer6/cpp-docs.git
cd cpp-docs && make install # make uninstall removes the linksThen ask for it by name (/modern-cpp), or just ask for modern C++.
Upgrading: run make update. It pulls the latest release (stay on main)
and re-links. The links point back at your checkout, so a plain git pull
upgrades the skills too. make install also upgrades an older install: it
re-points a link to another checkout, and moves an older copied folder to
~/.claude/skills-backup/ before linking. SKILLS_DIR=… make install
installs somewhere else.
Every reference page has the same shape:
- What it is — one-line summary, header, and the C++ version that introduced it.
- Mental model — how to picture it.
- Complexity / key facts — the numbers and rules that matter.
- When to use it (and when not to).
- Examples — short, focused, modern C++ snippets.
- Gotchas — the non-obvious traps.
- See also — where to read more.
- Testing and CI: checking the snippets, running the tests (also under AddressSanitizer, UBSan and ThreadSanitizer), the toolchain presets (local, portable, MSVC and clang-cl from a VS Developer shell, GCC 16 in Docker) and the manual GitHub Actions workflows.
- Platform support: the full results behind
the table below (counts, skip reasons, known gaps per toolchain), generated
by
tools/collect_results.py. - Running a workflow: how a consented run is started, watched and read.
Examples target the latest C++ standard and prefer modern idioms (CTAD,
structured bindings, ranges, auto, designated initializers, etc.). The C++
version is noted whenever a feature isn't available everywhere. The full house
style is in CLAUDE.md.
Latest release: v0.5.0 (2026-11-03). All
releases are listed in docs/releases/.
See docs/examples/README.md for the full index and
status across every topic.
MIT, © 2026 Steve Sperandeo: the notes, snippets, tests, tools
and skills in this repo. PRs are welcome under the same licence. The
submodules in modules/ keep their own licences: the
C++ Core Guidelines
allow copies for personal or internal business use only, so this repo links
to them instead of copying their text.
62 platform × compiler × architecture combinations, results as of 2026-11-03. Tests: GoogleTest cases passed / total; snippets: compile-checked blocks passed / checked. report-only: that toolchain's snippet results don't fail its run yet (no reviewed baseline). Skip reasons, known gaps and full counts: docs/platform-support.md, with the feature support matrix and one page per toolchain (every feature and example) in docs/platform-support/. The GitHub Actions runs here cover all areas (the areas input); the local runs cover the whole suite.
| Platform | Compiler | Arch | Tests | Snippets | Run |
|---|---|---|---|---|---|
| Linux (Docker) | GCC 16.2.0 | arm64 | ✅ 1505/1544 (39 skipped) | ✅ 1698/1698 (154 skipped) | local, 2026-11-03 |
| macOS (Darwin 23.6.0) | Clang 22.1.8, libc++ | arm64 | ✅ 1396/1541 (145 skipped) | ✅ 1679/1698 (19 baselined, 154 skipped) | local, 2026-11-03 |
| macOS (Darwin 23.6.0) | GCC 15.2.0 | arm64 | ✅ 1423/1541 (118 skipped) | ✅ 1698/1698 (154 skipped) | local, 2026-11-03 |
| FreeBSD 14.5 | Clang 21.1.8, libc++ | x86_64 | ✅ 1387/1544 (157 skipped) | ❌ 1675/1698 (19 baselined, 154 skipped, report-only) | 2026-11-03 |
| FreeBSD 15.1 | Clang 19.1.7, libc++ | x86_64 | ✅ 1350/1544 (194 skipped) | ❌ 1663/1698 (19 baselined, 154 skipped, report-only) | 2026-11-03 |
| Ubuntu 24.04 | Clang 22.1.8, libstdc++ | arm64 | ✅ 1398/1544 (146 skipped) | ❌ 1679/1698 (154 skipped, report-only) | 2026-11-03 |
| Ubuntu 26.04 | Clang 22.1.2, libstdc++ | arm64 | ✅ 1435/1544 (109 skipped) | ❌ 1691/1698 (154 skipped, report-only) | 2026-11-03 |
| Debian 12 | GCC 13.5.0 | x86_64 | ✅ 1323/1544 (221 skipped) | ❌ 1620/1698 (154 skipped, report-only) | 2026-11-03 |
| Debian 13 | GCC 14.4.0 | x86_64 | ✅ 1385/1544 (159 skipped) | ❌ 1664/1698 (154 skipped, report-only) | 2026-11-03 |
| Debian 13 | GCC 16.2.0, ASan+UBSan | x86_64 | ✅ 1503/1544 (41 skipped) | - | 2026-11-03 |
| Ubuntu 24.04 | Clang 21.1.8, libc++ | x86_64 | ✅ 1388/1544 (156 skipped) | ✅ 1681/1698 (17 baselined, 154 skipped, report-only) | 2026-11-03 |
| Ubuntu 24.04 | Clang 22.1.8, libc++, ASan+UBSan | x86_64 | ✅ 1398/1544 (146 skipped) | - | 2026-11-03 |
| Ubuntu 24.04 | Clang 23.1.5, libstdc++ | x86_64 | ✅ 1395/1544 (149 skipped) | ❌ 1679/1698 (154 skipped, report-only) | 2026-11-03 |
| Ubuntu 26.04 | Clang 22.1.2, libstdc++ | x86_64 | ✅ 1433/1544 (111 skipped) | ❌ 1691/1698 (154 skipped, report-only) | 2026-11-03 |
| macOS 15 | Apple Clang 17.0.0 | arm64 | ✅ 1338/1541 (203 skipped) | ❌ 1635/1698 (154 skipped, report-only) | 2026-11-03 |
| macOS 15 | Clang 23.1.4, libc++ | arm64 | ✅ 1402/1541 (139 skipped) | ✅ 1683/1698 (15 baselined, 154 skipped, report-only) | 2026-11-03 |
| macOS 26 | Apple Clang 21.0.0 | arm64 | ✅ 1375/1541 (166 skipped) | ❌ 1659/1698 (154 skipped, report-only) | 2026-11-03 |
| macOS 26 | Clang 23.1.4, libc++ | arm64 | ✅ 1402/1541 (139 skipped) | ✅ 1683/1698 (15 baselined, 154 skipped, report-only) | 2026-11-03 |
| macOS 26 | Clang 23.1.4, libc++, ASan+UBSan | arm64 | ✅ 1402/1541 (139 skipped) | - | 2026-11-03 |
| macOS 26 | Clang 23.1.4, libc++, hardened | arm64 | ✅ 1410/1541 (131 skipped) | - | 2026-11-03 |
| macOS 26 | Apple Clang 21.0.0 | x86_64 | ✅ 1373/1541 (168 skipped) | ❌ 1658/1698 (154 skipped, report-only) | 2026-11-03 |
| FreeBSD 14.5 | GCC 14.2.0 | x86_64 | ✅ 1373/1544 (171 skipped) | ❌ 1663/1698 (154 skipped, report-only) | 2026-11-03 |
| FreeBSD 15.1 | GCC 14.2.0 | x86_64 | ✅ 1365/1544 (179 skipped) | ❌ 1663/1698 (154 skipped, report-only) | 2026-11-03 |
| Debian 13 | GCC 15.3.0 | arm64 | ✅ 1435/1544 (109 skipped) | ✅ 1698/1698 (154 skipped) | 2026-11-03 |
| Debian 13 | GCC 16.2.0 | arm64 | ✅ 1505/1544 (39 skipped) | ✅ 1698/1698 (154 skipped) | 2026-11-03 |
| Ubuntu 24.04 | Clang 22.1.8, libc++ | arm64 | ✅ 1399/1544 (145 skipped) | ✅ 1681/1698 (17 baselined, 154 skipped) | 2026-11-03 |
| Ubuntu 24.04 | Clang 23.1.5, libc++ | arm64 | ✅ 1406/1544 (138 skipped) | ✅ 1687/1698 (11 baselined, 154 skipped, report-only) | 2026-11-03 |
| Ubuntu 24.04 | Clang 23.1.5, libstdc++ | arm64 | ✅ 1396/1544 (148 skipped) | ❌ 1679/1698 (154 skipped, report-only) | 2026-11-03 |
| Ubuntu 26.04 | Clang 22.1.2, libc++ | arm64 | ✅ 1402/1544 (142 skipped) | ✅ 1681/1698 (17 baselined, 154 skipped) | 2026-11-03 |
| Ubuntu 26.04 | GCC 15.2.0 | arm64 | ✅ 1442/1544 (102 skipped) | ✅ 1698/1698 (154 skipped) | 2026-11-03 |
| Debian 13 | GCC 15.3.0 | x86_64 | ✅ 1433/1544 (111 skipped) | ✅ 1698/1698 (154 skipped) | 2026-11-03 |
| Debian 13 | GCC 16.2.0 | x86_64 | ✅ 1503/1544 (41 skipped) | ✅ 1698/1698 (154 skipped) | 2026-11-03 |
| Debian 13 | GCC 16.2.0, hardened | x86_64 | ✅ 1502/1544 (42 skipped) | - | 2026-11-03 |
| Ubuntu 24.04 | Clang 18.1.8, libstdc++ | x86_64 | ✅ 1361/1544 (183 skipped) | ❌ 1665/1698 (154 skipped, report-only) | 2026-11-03 |
| Ubuntu 24.04 | Clang 19.1.7, libc++ | x86_64 | ✅ 1350/1544 (194 skipped) | ❌ 1668/1698 (17 baselined, 154 skipped, report-only) | 2026-11-03 |
| Ubuntu 24.04 | Clang 19.1.7, libstdc++ | x86_64 | ✅ 1387/1544 (157 skipped) | ❌ 1678/1698 (154 skipped, report-only) | 2026-11-03 |
| Ubuntu 24.04 | Clang 20.1.8, libc++ | x86_64 | ✅ 1374/1544 (170 skipped) | ❌ 1676/1698 (17 baselined, 154 skipped, report-only) | 2026-11-03 |
| Ubuntu 24.04 | Clang 20.1.8, libstdc++ | x86_64 | ✅ 1391/1544 (153 skipped) | ❌ 1678/1698 (154 skipped, report-only) | 2026-11-03 |
| Ubuntu 24.04 | Clang 21.1.8, libstdc++ | x86_64 | ✅ 1393/1544 (151 skipped) | ❌ 1679/1698 (154 skipped, report-only) | 2026-11-03 |
| Ubuntu 24.04 | Clang 22.1.8, libc++ | x86_64 | ✅ 1397/1544 (147 skipped) | ✅ 1681/1698 (17 baselined, 154 skipped) | 2026-11-03 |
| Ubuntu 24.04 | Clang 22.1.8, libstdc++ | x86_64 | ✅ 1395/1544 (149 skipped) | ❌ 1679/1698 (154 skipped, report-only) | 2026-11-03 |
| Ubuntu 24.04 | Clang 22.1.8, libstdc++, TSan | x86_64 | ✅ 1393/1544 (151 skipped) | - | 2026-11-03 |
| Ubuntu 24.04 | Clang 23.1.5, libc++ | x86_64 | ✅ 1404/1544 (140 skipped) | ✅ 1687/1698 (11 baselined, 154 skipped, report-only) | 2026-11-03 |
| Ubuntu 26.04 | Clang 22.1.2, libc++ | x86_64 | ✅ 1400/1544 (144 skipped) | ✅ 1681/1698 (17 baselined, 154 skipped) | 2026-11-03 |
| Ubuntu 26.04 | GCC 15.2.0 | x86_64 | ✅ 1440/1544 (104 skipped) | ✅ 1698/1698 (154 skipped) | 2026-11-03 |
| macOS 15 | GCC 16.2.0 | arm64 | ✅ 1494/1541 (47 skipped) | ✅ 1698/1698 (154 skipped) | 2026-11-03 |
| macOS 15 | Apple Clang 17.0.0 | x86_64 | ✅ 1335/1541 (206 skipped) | ❌ 1635/1698 (154 skipped, report-only) | 2026-11-03 |
| macOS 15 | GCC 16.2.0 | x86_64 | ✅ 1492/1541 (49 skipped) | ✅ 1698/1698 (154 skipped) | 2026-11-03 |
| macOS 15 | Clang 22.1.8, libc++ | x86_64 | ✅ 1394/1541 (147 skipped) | ✅ 1679/1698 (19 baselined, 154 skipped) | 2026-11-03 |
| macOS 26 | GCC 16.2.0 | arm64 | ✅ 1494/1541 (47 skipped) | ✅ 1698/1698 (154 skipped) | 2026-11-03 |
| macOS 26 | GCC 16.2.0 | x86_64 | ✅ 1492/1541 (49 skipped) | ✅ 1698/1698 (154 skipped) | 2026-11-03 |
| macOS 26 | Clang 22.1.8, libc++ | x86_64 | ✅ 1394/1541 (147 skipped) | ✅ 1679/1698 (19 baselined, 154 skipped) | 2026-11-03 |
| Windows 11 | MSVC 19.51.36260 | arm64 | ✅ 1372/1544 (172 skipped) | ❌ 1654/1679 (173 skipped, report-only) | 2026-11-03 |
| Windows Server 2022 | MSVC 19.44.35229 | x86_64 | ✅ 1342/1544 (202 skipped) | ❌ 1641/1679 (173 skipped, report-only) | 2026-11-03 |
| Windows Server 2025, MSYS2 CLANG64 | Clang 23.1.4, libc++ | x86_64 | ✅ 1394/1544 (150 skipped) | ❌ 1683/1698 (13 baselined, 154 skipped, report-only) | 2026-11-03 |
| Windows Server 2025, MSYS2 UCRT64 | Clang 23.1.4, libstdc++ | x86_64 | ✅ 1448/1544 (96 skipped) | ❌ 1687/1698 (154 skipped, report-only) | 2026-11-03 |
| Windows Server 2025, MSYS2 UCRT64 | GCC 16.2.0 | x86_64 | ✅ 1485/1544 (59 skipped) | ❌ 1694/1698 (154 skipped, report-only) | 2026-11-03 |
| Windows Server 2025 | clang-cl 22.1.3 | x86_64 | ✅ 1393/1544 (151 skipped) | ❌ 1658/1679 (173 skipped, report-only) | 2026-11-03 |
| Windows Server 2025 | MSVC 19.51.36260 | x86_64 | ✅ 1372/1544 (172 skipped) | ❌ 1654/1679 (173 skipped, report-only) | 2026-11-03 |
| Ubuntu 24.04 | Clang 18.1.8, libc++ | x86_64 | ✅ 1325/1544 (219 skipped) | ❌ 1658/1698 (17 baselined, 154 skipped, report-only) | 2026-11-03 |
| Ubuntu 24.04 | Clang 22.1.8, libc++, hardened | x86_64 | ✅ 1405/1544 (139 skipped) | - | 2026-11-03 |
| Windows Server 2025 | MSVC 19.51.36260, hardened | x86_64 | ✅ 1380/1544 (164 skipped) | - | 2026-11-03 |