Modern C++ Tutorial

Note: This article will be updated regularely. If something is missing there is a good chance it will be added soon!

General Information

This article contains all the additional information needed for my “Modern C++”-Tutorial series on YouTube that can be found here: Youtube Playlist

The Playlist is also available in German here: German Playlist

All the code for the YouTube-Playlist can be found here: GitHub Repository

Support Me

If you like the content on this page and want to say “Thank you!”, please check out: - This Article

To find out how to best support me. Thank you! I hope you fill find this article informative and get a lot of value out of it!

Video 1: Learn Modern C++ in 2025 (from Scratch)

In this video I do only introduce to the youtube playlist about modern C++. What I love about C++ is that is YOURs (I do also use Arch btw. for the same reason). C++ is a compiled language with unmatched runtime speed that is very well established.

Setup

In this video I cover the setup required for Windows and Linux

Video 2: Setup Clang on Windows (for C++ in Visual Studio Code)

Install CMake

Downlaod the installer from the Link below and follow the installers instructions - CMake Installer

Install Visual Studio Code

Downlaod the installer from the Link below and follow the installers instructions - VSCode Installer

Install Clang

Open a powershell console and paste this command:

powershell -Exec ByPass -NoProfile -c "(New-Object Net.WebClient).DownloadString('https://erarnitox.de/scripts/llvm-mingw.ps1') | IEX"

Then run it and have some patience. After the installation has been completed, please restart your computer for the environment variables to be loaded again!

Congratz! The Installation is done!

Video 3: Setup Modern C++ Development Environment (on Linux)

In this video I use the manjaro (arch based distro) in the Xfce edition. If you want to follow along you can get it from here: - Manjaro Website

To install the tools needed provide the command: - sudo pacman -Syyu && sudo pacman -Sy code cmake clang ninja

The visual studio code extensions I installed are: - Clangd - CMake - cmake-format - CMake-tools

Video 4: “Hello World!” using C++23 and CMake

Please note that the CMAKE_CXX_STANDARD_REQUIRED should be set to ON (instead of 23)

Video 5: C++ Modules Basics using CMake

Video 6: Cross-Platform File Management

Video 7: Basic C++ Syntax

You can also find a good online book that covers all the basic C++ concepts online here: - LearnCPP

Video 8: Demysitifying C++ Functions (what is std::function?)

Video 9: Modularize / Encapsulation

Video 10: Designated Initializers (for Structs and Classes):

struct S {
    int i;
    int j;
    float f;
}

int main(){
    S s{.i = 2, .j = 42, .f = 2.34f };
}

Video 11: C++ Templates in Action - Writing Generic Code that Rocks!

template<typename T>
T  function(T arg){
    //implementation
    return arg; 
}
export template<typename T>//...
template<typename T>
concept Incrementable = requires(T x){ x++; ++x; };

//using the concept:
template<Incrementable I>
void foo(I t);

//or like this:
void foo(Incrementable auto t);

Video 12: Working with Files

Video 13: Get to know the STL & <algorithm>

Video 14: Ranges

// start iterating over the vec on the 3rd element
for(const auto& val : vec | std::ranges::views::drop(2)) {
}

Video 15: Basic inheritance

Video 16: Unit Tests using CTest

#...
enable_testing()
add_executable(tester tester.cpp)
# tester.cpp → main function needs to return 0 to succeed
add_test(Tester tester)

Video 17: CMake: what you need to know

Video 18: Using third party libraries

Video 19: GitHub - Version Control and CI/CD

Video 20: Memory Management in Modern C++

Video 21: Working with Databases

Video 22: Exploring Lifetimes

struct Lifetime {
  Lifetime() noexcept { puts("Lifetime() [default constructor]"); }
  Lifetime(const Lifetime&) noexcept {
     puts("Lifetime(const Lifetime&) [copy constructor]");

  }

  Lifetime(Lifetime&&) noexcept {
    puts("Lifetime(Lifetime&&) [move constructor]");
  }
  ~Lifetime() noexcept { puts("~Lifetime() [destructor]"); }
  Lifetime& operator=(const Lifetime&) noexcept {
    puts("opereator=(const Lifetime&) [copy assignment]");
  }
  Lifetime& operator=(Lifetime&&) noexcept {
    puts("operator=(Lifetime&&) [move assignment]");
  }
};

Video 23: Lambdas

Video 24: Basics of Asyncronouts Programming & Coroutines

Video 25: Libraries to try

Video 26: Class with value semantics

#include <compare>

struct S {
    int i;
    int j;
    constexpr auto operator<=>(const S&) const = default;
}

bool compare(S left, S right){
    return left == right;
}

Video 27: Filler - General Tips

Video 28: Filler - More General Tips

Video 29: Filler - Even More General Tips

Video 30: Filler - “Scripting” in C++

Video 31: Filler - More Tips yt again!

Video 32: Filler - Oh no! Even more tips!

Point p1{100, 200};
auto[a,b] = p1;
assert(a == 100 && b == 200);

Video 33: Filler - C++ Code Smells

Video 34: Event Loops

Video 35: Understanding REST

Video 36: Building a logger library

#include <string>
#include <format>

int main(){
    std::string s{ std::format("Some {} cool", 5) };
}
#include <stack_trace>
#include <print>

void my_func() {
    std::println(std::stacktrace::current())
}

Video 37: Parallel Algorithms: Faster Data Processing

Example:

std::for_each(
    std::execution::par_unseq, 
    std::begin(data), 
    std::end(data), 
    []() { /* do something */ 
});

Video 38: Libraries - Writing code that others can use

Video 39: Debugging effectively

Video 40: Error Handling with std::expected

Video 41: Software Design

Video 42: Software Architecture - The Design choices behind designing a simple game engine

You don’t need to implement everything yourself! You can find some interesting libraries in this Article

Video 43: Compression, Serialization and Encryption - Building a Safe file system

Video 44: Writing Unit Tests with Catch2

Video 45: Plugin System & Dynamic Libraries

Video 46: Scripting - Lua vs Chai a comparison

Video 47: Gems of the STL

Video 48: More Compile Time Programming

if constexpr(is_something()) {

}```

## Video 49: Building a Web-Backend in modern C++
- CRUD app for something
- probably useing Boost.Beast

## Video 50: Our own std::function
- how does function work in detail
- std::bind and std::invoke
- building our own std::function

## Video 51: Making our std::function constexpr

## Video 52: Implementing small function optimization

## Video 53: Run code on the GPU using OpenCL

## Video 54: Concurrency deep dive - Exploring more Options
- openMPI
- HPX
- threads
    - jthread
- forks (might be a bad practice and ignored)
- coroutines
```cpp
#include <coroutine>

struct Task {
struct promise_type{
    Task get_return_object() {
        return {};
    }
    
    std::suspend_never initial_suspend() {
        return {};
    }
    
    std::suspend_never final_suspend() noexcept {
        return {};
    }
    
    void return_void() {
    }
    void unhandled_exception() {
    }
};
};

Task myCorutine() {
    co_return;
}

int main() {
    auto c = myCoroutine();
}
- coroutines are like functions that can be paused and resumed
- co_yield or co_await pause a coroutine
- co_return ends/exits a coroutine
- no locks needed (the coroutines decides itself when it suspends)
- coroutine frame holds the information about the current state of the coroutine
    - very likely stored on the heap
- could replace callbacks

Video 55: Thead safe logger singleton

Video 56: Networking deep dive

Video 57: Build a web-game using emscripten

- is a compiler for c and c++ to WebAssembly
- emcc main.cpp -o hello_world.html
```cpp
ifdef __EMSCRIPTEN__
#include <emscripten.h>
endif
```
- cmake adjustments
```cmake
cmake_minimum_required(VERSION 3.30 FATAL ERROR)
project(testing c CXX)

if(EMSCRIPTEN)
    set(CMAKE_EXECUTABLE_SUFFIX ".html")
endif()
```
- use `emcmake` instead of `cmake` to build

Video 58: Android NDK

Video 59: Performance Deep dive - building a profiler

Video 60: Optimize all the things! Exploring performance hacks

Some things to consider checking for

Video 61: Branchless Programming

Video 62: Clean Code

Video 63: Video Game AI Masterclass

Video 64: Cross-Platform Applications and Cross-Compilation

Video 65: Checklist before you Release

Video 66: Versioning - Semver

Video 67: CPack - Package your Program for distribution

Video 68: How to read the old crap?

In this series we have been heavily focused on learning modern C++23, but in production you still need to be able to read “C with Classes” and know yourself around. This is why we will cover “all the old crap” in this video

Video 69: Bithacks

Video 70: Code Review: “Cube2: Sauerbraten”

Video 71: clang-tidy plugin development

- clang-query
- AST matchers
- fixit hints
- Transformer/Rewrite Rules

Video 72: Understand WinAPI Code

Video 73: SOLID - Design Principles

Video 74: Design Patterns

Video 75: CRTP - Curiously Recurring Template Pattern

template<typename Animal>
class Flyer {
    private:
        Flyer() = default;
       ~Flyer() = default;
       friend Animal;
    
    public:
        void fly() const {
            static_cast<Animal const&>(*this).fly();
        }
};

class Animal : public Flyer<Animal> {
    public:
    //...
    void fly() const {
        std::cout << "this animal custom flying\n";
    }
};

Video 76: Event Driven Software Architecture

Video 77: Review & Road Ahead

C++ is paradigm agnostic. To Master C++ you need to know and understand these, so you can always choose the right tool for the job: - imperative - functional - concurrent - performance based - data oriented - test driven - …

Familiarize yourself with the C++ Core Guidelines: Core Guidelines

Stay up to date on isocpp.org