Companion source code for "Programming with C++20 - Concepts, Coroutines, Ranges, and more"

Overview

Companion Source Code for "Programming with C++20 - Concepts, Coroutines, Ranges, and more" 1. Edition

Build Status License

Book cover

Code examples

This repository contains runnable source code examples from the 1. edition of Programming with C++20 - Concepts, Coroutines, Ranges, and more, by Andreas Fertig.

The layout of the examples

The examples are separated into different directories based on how they appear in the book.

Running the examples

The examples are contained in a single .cpp file that can be easily executed in any IDE. There is also an CMakeLists.txt which can generate IDE projects or used to compile the example in a terminal. This repo contains a top-level CMakeLists.txt which does build all the examples.

Building the examples

You can select the compiler by setting the CXX environment variable.

mkdir programming-with-cpp20
cd programming-with-cpp20
git clone https://github.com/andreasfertig/programming-with-cpp20
mkdir build
cd build
cmake ../
cmake --build . -j

After that you find all the executables in programming-with-cpp20/build/bin.

Some of these examples use the latest C++ standard, so you will need a modern compiler in order to compile them. The latest stable versions of GCC or Clang are recommended. The code is not tested, but expected to work, with MSVC as well.

License

The source code is released under the MIT License.

You might also like...
Rasdisys Open Source code for a LTE eNB on Qualcomm FSM9955

Downloaded on June 1st, 2021 from https://www.radisys.com/OpenRadisys-4G-RAN-Software which clearly stated that this code was licensed under GNU AGPLv

Flutter-v2 Firebase Messaging, Foreground and Background Notifications + Topic Subscription and Broadcast Notifications Source code

Flutter Notification & FCM The repo is about flutter notification and FCM (Firebase Cloud Messaging). It is updated with Flutter v2 and new updates of

Some source code to demonstrate avoiding certain direct syscall detections by locating and JMPing to a legitimate syscall instruction within NTDLL.

hiding-your-syscalls What is this? This repository contains all of the source code from my blog post about avoiding direct syscall detections, which y

Open source release of challenges and other code used in the Hack-A-Sat 2 Qualifier in 2021.

Hack-a-Sat 2 Qualifier This repository contains the open source release for the Hack-a-Sat 2 qualifier from 2021. Released artifacts include: Source c

Despertar del Cementerio and M33 CFW source code

DC-M33 Despertar del Cementerio and M33 CFW source code This project is a continuation of the M33 Team's work with using modern technics and exploits.

Source Code for 'Clean C++20' by Stephan Roth

Apress Source Code This repository accompanies Clean C++20 by Stephan Roth (Apress, 2021). Download the files as a zip using the green button, or clon

Fully reverse engineered source code of a pasted valorant spoofer called archine.

Archine Valorant Spoofer Fully reverse engineered source code of a pasted valorant spoofer called archine. Please do not buy archine spoofer, the owne

A Bouncing Seal Discord Bot's Source Code.

A Bouncing Seal It's a fun bot with leveling and funny bouncing seal videos. Information Invite Support Server How to run locally You need DPP, follow

Historic source code for version 0.01 of the Linux kernel

Linux v0.01 Source Code (A historic repository of the first official release of the Linux Kernel) About This Repo This repo is a means of keeping and

Comments
  • Coroutine set

    Coroutine set

    Thanks for the coroutine set.

    The evolution of samples from the first one(02.10) to the result is awesome and produces the expected results. However, what if one would use it from the perspective to write something more generic:

    For example the data for "sending coroutine" could be just:

        std::vector<byte> fakeBytes {
            'H'_B, 'e'_B, 'l'_B, 'l'_B, 'o'_B
        };
    

    and the code in "parsing coroutine" is co-awaiting and just co-yielding (echoing):

        while (true) {
            byte b = co_await byte{};
            std::string frame{};
            frame.push_back(static_cast<char>(b));
            co_yield frame;
        }
    

    And in this sense the modified (02.10) keeps working as expected, but already the next one doesn't (is crashed). Of course, things were done with an eye to a specific version of the protocol, the outcomes in common seem not functionally equivalent. And I thought that the issues could be interesting.

    opened by wiluite 0
  • 02.25-coroutineParsingDataStreamCustomAllocator1 compile error with Ubuntu-GCC 12.1

    02.25-coroutineParsingDataStreamCustomAllocator1 compile error with Ubuntu-GCC 12.1

    The error message is hard to understand. It seems like type-cast related. main.cpp:284:1: error: ‘static void promise_type_base<T, G, InitialSuspend>::operator delete(void*, size_t) [with T = std::__cxx11::basic_string<char>; G = generator<std::__cxx11::basic_string<char>, false>; bool InitialSuspend = false]’ called on pointer returned from a mismatched allocation function [-Werror=mismatched-new-delete] 284 | } | ^ 02.25-coroutineParsingDataStreamCustomAllocator1/main.cpp:284:1: note: returned from ‘static void* promise_type_base<T, G, InitialSuspend>::operator new(size_t, arena&, TheRest&& ...) [with TheRest = {DataStreamReader&}; T = std::__cxx11::basic_string<char>; G = generator<std::__cxx11::basic_string<char>, false>; bool InitialSuspend = false]’ /home/wps/cpp20/coro-study/02.25-coroutineParsingDataStreamCustomAllocator1/main.cpp: In function ‘generator<std::byte> sender(arena&, std::vector<std::byte>)’: 02.25-coroutineParsingDataStreamCustomAllocator1/main.cpp:292:1: error: ‘static void promise_type_base<T, G, InitialSuspend>::operator delete(void*, size_t) [with T = std::byte; G = generator<std::byte>; bool InitialSuspend = true]’ called on pointer returned from a mismatched allocation function [-Werror=mismatched-new-delete] 292 | } | ^ 02.25-coroutineParsingDataStreamCustomAllocator1/main.cpp:292:1: note: returned from ‘static void* promise_type_base<T, G, InitialSuspend>::operator new(size_t, arena&, TheRest&& ...) [with TheRest = {std::vector<std::byte, std::allocator<std::byte> >&}; T = std::byte; G = generator<std::byte>; bool InitialSuspend = true]’ cc1plus: all warnings being treated as errors

    opened by 19317362 1
  • constructor argument evaluation IMHO not necessarily left to right

    constructor argument evaluation IMHO not necessarily left to right

    The following code might read errno before calling open... I am happy to be convinced otherwise.

    https://github.com/andreasfertig/programming-with-cpp20/blob/491c83d0991ba70b3b0b42f671ba92654e897a37/08.30-structuredBindingsPOSIXError4/main.cpp#L23

    opened by PeterSommerlad 1
Owner
Andreas Fertig
Trainer, Speaker, Programmer all around C++ and Embedded Systems. Creator of https://cppinsights.io
Andreas Fertig
Companion repository to the "Modern Embedded Systems Programming" video course.

What is it? This repository is a companion to the "Modern Embedded Systems Programming" video course, which consists of focused, fast-paced, hands-on

Quantum Leaps 216 Dec 31, 2022
Project is to port original Zmodem for Unix to CP/M and provide binaries and source code for platform specific modification as needed. Based on 1986 C source code by Chuck Forsberg

Zmodem-CP-M This repository is intended to foster a RetroBrewComputers community effort to port the original Zmodem source code for Unix to CP/M so ev

null 11 Aug 31, 2022
Project is to port original Zmodem for Unix to CP/M and provide binaries and source code for platform specific modification as needed. Based on 1986 C source code by Chuck Forsberg

Zmodem4CPM This repository is intended to foster a RetroBrewComputers community effort to port the original Zmodem source code for Unix to CP/M so eve

null 11 Aug 31, 2022
Source code for the article "Code vs Data Driven Displacement"

Code vs Data Driven Displacement This repo contains the source code for all the demos from this article. It uses raylib or more specifically raygui so

Daniel Holden 421 Dec 29, 2022
Phan Sang 17 Dec 29, 2022
Reverse engineered source code of the engineowning cheat for cod9 (tags, ignore. Fortnite cheat, engineowning, engineowning cracked, cheat cracked, cod cracked cheat, cod cheat source)

engineowning-cod9 Reverse engineered source code of the engineowning cheat for cod9 Cracked by CODEX notinjector = C:\Windows\Release\ .exe drSYS = C:

null 8 Oct 12, 2022
A simple processor emulator written in c++ that can parse and execute x32 code. x32 is binary code made by me for this processor.

A SIMPLE PROCESSOR EMULATOR AND CODE EXECUTOR The Repository This is a fairly new project and is still heavy in development. If you find and bugs feel

Luka Golob 4 Jan 20, 2022
This is a compilation of the code and images for all Arduino code in the Robotics 11 class.

Robotics 11 - Arduino This is a compilation of the code and images for all Arduino code in the Robotics 11 class. All code can be viewed in each proje

GuhBean 1 Oct 29, 2021
This is the source code of SATCH a SAT solver written from scratch in C.

The main purpose of this solver is to provide a simple and clean code base for explaining and experimenting with SAT solvers. It is simpler than the source code of CaDiCaL and of Kissat in particular, while still featuring most important implementation techniques needed to obtain a state-of-the-art SAT solver

Armin Biere 73 Dec 16, 2022
Official Vanguard Anti-Cheat source code.

Vanguard Official Vanguard Anti-Cheat source code. Using the compiled binary For ease, an unprotected compiled version of Vanguard is available. Downl

Riot Vanguard 435 Jan 5, 2023