Strong types for strong interfaces

Speaker: Jonathan Boccara

Audience level: Intermediate

Abstract

Strong types are such a powerful tool for bringing expressiveness into code. By using them we can precisely state our intentions about our C++ objects, both to compilers and to human beings reading our code.

This topic has been popular for years in the C++ community, notably with an implementation in Boost (strong typedef), and proposals for standards. Actually, std::chrono already intensively uses strong typing.

In this talk, you will see what strong types are, how they can make your code clearer, and whether or not you will incur a performance cost in your code by using them. We will see various usages of strong types, including units and named parameters. This will be based on a simple implementation of generic strong typing that I am proposing and that was already presented to many people.

But I want to take this topic further, by also showing practical aspects of strong types that do come up in real code, which includes: - Passing strong types by reference, - Strong typing over generic types, or otherwise unknown types like lambdas, - Inheriting functionalities from the underlying type, - Converting strong types to one another.