Modern C++: When Efficiency Matters


Course Description

You want to learn how to write efficient C++ because you

  • care for the speed of your product?
  • like to write robust code?
  • write code for a constrained device?

Then consider this class!

You will learn about various features of modern C++, how they work, where to use them, and how they translate to code. With that knowledge, you understand what each feature brings you and its costs regarding code size and performance.

You will learn how to write less code and get the same result. Less code helps you to save human resources when it comes to maintenance and debugging.

In times when a lot of applications are battery-powered, saving run time is a great asset. As part of this class, you will learn to control your binary's footprint and speed.

You will learn all topics with exercises and live demos in C++ Insights and Compiler Explorer.

Course Outline

  • How a std::initializer_list works
  • Scope control using if or switch with initialization
  • Safe and efficient constructors
    • Default member initialization
    • Constructor inheritance and its trap
  • How to get good performance
    • Alignment and padding
    • The importance of caching
    • How noexcept helps you
    • static vs. inline
    • The powers of CTAD
  • Under the hood of lambdas
    • Lambda captures and their implications
    • Generic as well as templated (includes C++20)
  • Templates
    • Variadic templates
    • Recursive variadic templates vs. fold-expressions
    • Guidelines for efficient use of templates
  • Devirtualize your virtual functions with final
  • How a local non-trivial static variable works
  • The power of compile-time vs. run-time
    • How and when to apply constexpr
    • How to achieve constant initialization
    • Select only the data you need with constexpr if
  • Move-semantics
    • Move or copy?
    • The difference between std::move vs std::forward
    • Make your move-operations noexcept: noexcept, move, and STL containers
    • Implicit moves
  • Know the costs of the abstraction: shared-/unique-ptr
  • Using the STL efficiently
    • Chose the right container for your data
    • Best to use container methods for performance

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

Aside from my in-house classes, I offer open-enrollment courses occasionally. They take place online via Zoom, approx. 10 am - 2 pm EDT over five days. If you're interested, please subscribe for updates.

These fields are required.