Class - 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 where a lot of applications are battery-powered, saving run-time is a great asset. As part of this class, you will learn to control the footprint and the speed of your binary.

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

Course Outline

  • Type-deduction surprises
  • Range-based for-loops how they work and what you have to watch out for
  • How noexcept helps you
  • How a std::initializer_list works
  • Scope control using if or switch with initialization
  • Safe and efficient constructors
    • In-class member initialization
    • Constructor inheritance and its trap
  • Under the hood of lambdas
    • Lambda captures and their implications
    • Generic as well as templated (a preview into C++20)
  • Structured bindings
  • 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
  • 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

These fields are required.