Skip to content
binshelf/ cpp

Search lessons

Type a C++ term, like vector, reference, unique_ptr or use-after-free.

    About

    A free course in modern C++, one concept at a time, for building low-level, AI and bioinformatics tools.

    How the examples are checked

    Before anything is published, every C++ example is formatted with clang-format, compiled as C++23 with GCC 15 and Clang 21 with warnings treated as errors, and run with AddressSanitizer and UndefinedBehaviorSanitizer turned on. When an example shows output, it must print exactly that output.

    Examples marked "Does not compile" or "Fails when run" are checked too: they must fail, and the message you see under them is the real one from the compiler or the sanitizer. A few examples use library features GCC 15 doesn't have yet, such as std::mdspan; those are built with Clang and its own standard library, libc++.

    Examples made of several files are built the way the page shows: with g++, or with CMake and Ninja when they have a CMakeLists.txt, using GCC and then Clang. Testing examples use Catch2 3.

    Examples about threads run with ThreadSanitizer, which finds data races. Assembly listings are GCC's real output at the optimization level shown. Parallel algorithms use TBB 2022. Python examples use Python 3.14, pybind11 3 and NumPy 2.3, and WebAssembly examples are built with Emscripten 3.1 and run with Node.js 22. Half-precision examples (std::float16_t) are GCC only: Clang 21 doesn't have them yet. Examples use AVX2 vector instructions, which most x86-64 computers from the last ten years have.

    The Run button opens the example in Compiler Explorer, a free website not run by binshelf, with the same compiler and options.

    What this site stores

    Nothing about you is sent to or stored on a server. There are no accounts, analytics, ads or third-party scripts.

    One setting is kept in your browser's local storage, and never leaves it:

    • bs-cpp-progress: which lessons you've marked as done.

    Your light or dark theme choice is shared by all binshelf sites, in a cookie on binshelf.dev.

    Pages you open are also saved in your browser's cache storage on this device, so you can read them offline (see below). They never leave the device, and you can remove them.

    Offline reading and installing

    Pages you open are saved in this browser, so you can read them again without a connection. To read the whole course offline, save all lessons. Running code in Compiler Explorer still needs a connection.

    Offline reading needs JavaScript.

    Installed as an app, the course opens in its own window and works offline.

    • Chrome or Edge, on a computer or Android: Install app above, or Install in the address bar or browser menu.
    • Safari on iPhone or iPad: tap Share, then Add to Home Screen.
    • Safari on a Mac: File, then Add to Dock.

    Not an official C++ resource

    This site is not affiliated with or endorsed by ISO, the C++ standards committee (WG21) or the Standard C++ Foundation. For the reference documentation of the language and library, seecppreference.com.