Tag Archives: type erasure

Another polymorphism

In this post we will try to see by a practical example what Boost.Variant is for. You can sometimes see examples that use type variant<int, double, string>, but to me they are artificial: I never needed to use something that … Continue reading

Posted in programming | Tagged , , , , , | 20 Comments

Type erasure — Part IV

Update. The information about boost::hold_any was imprecise. This tool does not work just for any type, but requires that the type provides operators << and >> for writing into and reading it from IOStreams. In this post we will be … Continue reading

Posted in programming | Tagged , , | 8 Comments

Type erasure — Part III

Update. My advice about using Boost.Pointer Container library was based on the false understanding of the library. It could even cause bugs. This has now been corrected. This is the third part of the series of posts on type erasure. … Continue reading

Posted in programming | Tagged , , | 15 Comments

Type erasure — Part II

In the previous post, we have seen that there is a number of ways to erase the type of an object while still holding a “handle” to it and being able to make use of it. This can be summarized … Continue reading

Posted in programming | Tagged , , , , | 6 Comments

Type erasure — Part I

Have you ever came across term type erasure in C++? This “pattern” or “technique” is growing more and more popular. In this post I will try to describe what it is. Note that it is something different than a similar … Continue reading

Posted in programming | Tagged , , , | 17 Comments