Type Erasure, Part 2 -- Andrzej Krzemieński

In part 1, Andrzej explained what "type erasure" is all about. But how do you create custom type-erased interface?

Type Erasure, Part 2

by Andrzej Krzemieński

From the article:

While there are many ways to erase a type, I will use name type erasure to denote the usage of std::function-like value-semantic interface. This convention appears to be widely accepted in C++ community.

... Using std::function is easy, but this is because someöne has made an effort to implement it for us. So let’s try to see how much effort it is to write our own type-erased interface. We will be using countdown counters: something that (1) can be decremented and (2) tested if the count reached zero.

Add a Comment

Comments are closed.

Comments (0)

There are currently no comments on this entry.