More C++ Idioms/Parameterized Base Class

= Parameterized Base Class =

Intent
To abstract out an aspect in a reusable module and combine it in a given type when required.

Also Known As

 * Mixin-from-below
 * Parameterized Inheritance

Motivation
A certain aspect can be abstracted out from requirements and be developed as templates (e.g., object serialization). Serialization is a cross-cutting concern that many classes/POD types in an application may have. Such a concern can be abstracted out in a manageable reusable module. By addition of an aspect, substitutability with the original type is not broken so another motivation is to have a IS-A (public inheritance) or WAS-A (private inheritance) relationship with the type parameter.

Solution and Sample Code
Serializable  can be used polymorphically as a T as well as a ISerializable. Above example works correctly only if T is a user-defined POD type without pointers.

Related Idioms

 * Curiously Recurring Template Pattern