Implementation Challenge: Traits for Concepts with optional functionality

Traits classes are very powerful. They allow to associate information and functionality with arbitrary classes in a non-intrusive way. This makes it possible to use any type in a certain template as long as all access is done through the traits and there is an appropriate specialization.

The default specialization often just forwards to a member function. But for some functionality the types don’t necessarily need to provide it, it’s optional. Then the traits define a default implementation that is used as a fallback. In this post, I will show you how to implement such traits classes.

» read more »
Author's profile picture Jonathan

Controlling overload resolution #4: SFINAE

Overload resolution is one of C++ most complicated things and yet it works most of the time without the need to think about it. In this mini-series, I will show you how to control this complex machinery so it is even more powerful and completely under your control.

The fourth post shows you a weirdly named and powerful alternative to tag dispatching: SFINAE.

» read more »
Author's profile picture Jonathan

Controlling overload resolution #3: Tag dispatching

Overload resolution is one of C++ most complicated things and yet it works most of the time without the need to think about it. In this mini-series, I will show you how to control this complex machinery so it is even more powerful and completely under your control.

The third post shows you the power of tag dispatching to select from multiple implementations of a (templated) function. This allows powerful optimization for types with special properties.

» read more »
Author's profile picture Jonathan

Controlling overload resolution #2: Improving error messages for failed overload resolution

Overload resolution is one of C++ most complicated things and yet it works most of the time without the need to think about it. In this mini-series, I will show you how to control this complex machinery so it is even more powerful and completely under your control.

The second post shows you a simple way to improve the error messages when overload resolution fails and how to customize it completely.

» read more »
Author's profile picture Jonathan

Controlling overload resolution #1: Preventing implicit conversions

Overload resolution is one of C++ most complicated things and yet it works most of the time without the need to think about it. In this mini-series, I will show you how to control this complex machinery so it is even more powerful and completely under your control.

The first post shows you how to delete candidates and how you can use that to prevent implicit conversions.

» read more »
Author's profile picture Jonathan

Advertisement