Technology

Type Erasure in C++ and Variadic Templates

With the acceptance of the new C++ specification – code named C++0x, a slew of new programming techniques have become available to the programmers. One such technique – Variadic Templates is probably one of the most awaited features of the language. This post presents a solution to the problem of dealing with heterogeneous type collections without using Variadic templates – by using a technique known as Type Erasure as an alternate design technique, at least till such time as the support for Variadic Templates becomes more commonplace.

The problem presented in this post deals with OMG DDS specification, creating a multi-topic reader using a collection of topic specific data readers in C++, the problems therein and how Type Erasure can be used to overcome these problems. The technique is not limited to DDS and can be applied across other scenarios as well, such as game programming.

Share This Article:
  • Digg
  • Sphinn
  • del.icio.us
  • Google Bookmarks
  • Reddit
  • Slashdot
  • StumbleUpon
  • Technorati
Page 1 of 212