Programming With C++20 [2021 class archive]

Programming With C++20 is a three-day online training course with programming exercises taught by Andreas Fertig. It is offered online from 09:00 to 15:00 Aurora time (MDT), 11:00 to 17:00 EDT,  17:00 to 23:00 CET, Monday, November 1st through Wednesday, November 3rd, 2021 (after the conference).

Course Description

You will start learning about one of C++20’s biggest revolutions, Concepts. They make templates way less scary and, at the same time, give your more fine control to specify the interfaces of your templates. You learn how Concepts work and how to create your own Concept. Your learning continues with a look at a new form of writing function templates: abbreviated function templates. In the end, you learn how Concepts improve error messages.

Your next stop is coroutines. They are a beautiful new way to write asynchronous code and leaving heavy lifting to the compiler. This feature can reduce your finite state machines big time. You learn to rethink how function calls work and how regular functions compare to Coroutines. After that, you familiarize yourself with the low-level Coroutine API C++20 offers. You then learn how to use that knowledge to build a byte-stream parser using a Coroutine.

While you have seen two big language updates at this point, you will now learn about the improvements of the STL: Ranges. You will also learn about the improvements Ranges give you, like unintentional use of a temporary which is no longer valid.

Ranges are followed by the new ways of formatting a string using std::format. You will learn how std::format combines the best parts of iostreams and snprintf. Part of this learning is using std::format together with a custom buffer.

You then will learn about how easy comparisons can be in C++20 and how much less code you have to write, creating a simple class that supports all six comparisons. The start is a recap of what you had to do before C++20, followed by how your code now boils down to just a few lines of code using the spaceship-operator and a new compiler ability call operator-rewrites. You will then learn about some situations where upgrading C++17 code could lead to unexpected issues.

You started learning about a huge part of the improvements to templates with Concepts, but there is more. It is time that you learn about the new types you can use as non-type template parameters.

Of course, you will also learn about minor elements like starts_with for std::string or std::source_location to further remove the need for macros.

Every release since C++11 did improve the things we can do with constexpr. C++20 is no exception. Besides the new things you can do in a constexpr-context, you will also learn about two new elements of the constexpr-family: consteval and constinit. In the end, you will be able to set all three in a complete picture knowing which one of them to use when best.

After the seminar, you will have a clear understanding of what C++20 adds to the plate. You can consciously select features from the new language standard for a project and use them safely.

All attendees get a complimentary copy of the book “Programming with C++20” (https://fertig.to/bpwcpp20)

Prerequisites

Students are expected to have a basic knowledge of C++11. Constructs from later standards will be introduced if required.

Course Topics

  • Concepts
  • Coroutines
  • Ranges
  • Modules
  • std::format
  • spaceship-operator
  • Template updates
    • Class types as non-type template parameters
    • More CTAD
  • Lambda improvements
  • More constexpr
    • Allocate memory during compile-time
    • Execute function guaranteed at compile-time
    • Initialize variables at compile-time with the ability to change them later

Register Here

Course Instructor

Andreas Fertig

Andreas Fertig, CEO of Unique Code GmbH, is an experienced trainer and lecturer for C++ for standards 11 to 20.

Andreas is involved in the C++ standardization committee, in which the new standards are developed. At international conferences, he presents how code can be written better. He publishes specialist articles, e.g., for iX magazine, and has published several textbooks on C++.

With C++ Insights (https://cppinsights.io), Andreas has created an internationally recognized tool that enables users to look behind the scenes of C++ and thus to understand constructs even better.

Before working as a trainer and consultant, he worked for Philips Medizin Systeme GmbH for ten years as a C++ software developer and architect focusing on embedded systems.