Agenda: C++: Advanced Topics#

Introduction: A New Language To Me#

Range Based for Loops#

Tuple Unpacking (err, Structured Binding)#

Duck Typing (err, auto) Without A Duck#

Brace Initialization#

From Brace Initialization (Uniform Initialization)

New OO keywords: override, final, default, delete#

constexpr, constinit, consteval#

Functions: std::function<>, Lambdas#

Strongly Typed enum#

Delegating Constructor#

nullptr#

Moving, RValue References: Do We Want To Copy Sensors?#

Moving: Usage#

From Smart Pointers: std::unique_ptr, std::shared_ptr (And std::weak_ptr):

Moving: Implementation#

Building upon the example from Move Semantics, Rvalue References which is

  • Pointless

  • It implements a pointless String class that does resource management

Do some initial live hacking

Live-code a sensor class for Linux and OneWire (using DS18B20 Temperature Sensor as Slave)

  • Show problems ⟶ copy!

  • ⟶ rule of five

  • Inhibit copy

  • Implement move

Round it up: && is not always what you think 👎 🖕

  • Perfect Forwarding (a feature which shares the syntax with moving in that it uses &&, but is something completely different)

Type Erasure#

Allocators#

Ugh. Try to come up with something. Urgh.

C++ Pythonic Toolcase#

  • std::any

  • std::optional

  • std::variant

Concepts#

From Concepts

Multithreading#

From Multithreading, C++ Memory Model:

Outlook In >=20#

Miscellaneous#

Attributes And The Like#

  • [[nodiscard]]: Was bedeutet das?

  • [[fallthrough]]: Was bedeutet das?

  • noexcept

<algorithm> Overview#

  • std::transform

  • std::find

  • std::find_if

  • std::lower_bound

Miscellaneous Miscellaneous#

  • const overloading

  • user-defined literals

  • std::string_view