Class - Modern C++: When Efficiency Matters


Course Description

Although we live in a time when computers have more and more resources, there are still systems which are constraint in memory, CPU or other hardware.

To get good code even for such projects it helps to know how certain features in C++ work. In this class we talk about the new features since C++11 and how they translate to code.

This gives you a good understanding of what each feature costs. We do so by using C++ Insights (cppinsights.io) and Compiler Explorer (godbolt.org)to peak into the world of the compiler.

Aside from controlling the resulting code, we will also look to implement things with less code, this helps to save the human resource when it comes to maintenance and debugging.

In case, we have time at the end, we will have a brief look behind coroutines from C++20.

Course Outline

  • Compile-time vs. run-time
  • Type-deduction surprises
  • Range-based for-loops
  • noexcept
  • What is a std::initializer_list
  • Narrow the scope of a variable: if / switch with initialization
  • Constructor inheritance and its trap
  • In-class member initialization
  • Lambdas: Generic as well as lambdas with a template-head (a preview into C++20)
  • Lambda captures: Know what will be captured
  • Structured bindings
  • Variadic templates
  • Recursive variadic templates vs. fold-expressions
  • CTAD (Class template argument deduction)
  • How a local non-trivial static variable works
  • Move-semantics
  • Know the costs of the abstraction: shared-/unique-ptr
  • coroutines (optional)

Keep me informed

These fields are required.