Class - Programming with C++20

You are already using C++11 or newer and like to upgrade your knowledge with all the great new elements of C++20? Then join this course!

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 are coroutines. They are a beautiful new way to write asynchronous code and leaving the 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 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.

Course Outline

  • 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

Included in this course are

  • A handout as color PDF, which includes all references and an acronyms list;
  • The source code for the exercises as well as sample solutions for all exercises as a zip-file;
  • Certificate of attendance;
  • A complimentary copy one of my books

Keep me informed

These fields are required.