Modern C++ Tutorial

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

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

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: Basics of Modules and CMake

Video 6: Renaming Files in Bulk using std::filesystem

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: Functions

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: Working with Databases

Video 20: Memory Management in Modern C++

Video 21: Libraries to try

Video 22: GitHub - Version Control and CI/CD

Video 23: 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 24: Filler - General Tips

Video 25: Filler - More General Tips

Video 26: Filler - Even More General Tips

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

Video 28: Filler - More Tips yt again!

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

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

Video 30: Filler - C++ Code Smells

Video 31: Basics of Asyncronouts Programming & Coroutines

Video 32: Event Loops

Video 33: Understanding REST

Video 34: 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 35: 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 36: Parallel Algorithms: Faster Data Processing

Example:

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

Video 37: Libraries - Writing code that others can use

Video 38: Debugging effectively

Video 39: Error Handling with std::expected

Video 40: Software Design

Video 41: 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 42: Compression, Serialization and Encryption - Building a Safe file system

Video 43: Writing Unit Tests with Catch2

Video 44: Plugin System & Dynamic Libraries

Video 45: Scripting - Lua vs Chai a comparison

Video 46: Gems of the STL

Video 47: More Compile Time Programming

if constexpr(is_something()) {

}```

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

## Video 49: Lambdas
- how to lamdas work
- templated lambda expressions
    - lambdas can have "auto" parameters that work equivalent to templated parameters
- function attributes for lambda functions

## 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