A Solution to the Constructor-Problem of Mixin-Based Programming in C++

TitleA Solution to the Constructor-Problem of Mixin-Based Programming in C++
Publication TypeConference Paper
Year of Publication2000
AuthorsEisenecker, U., F. Blinn, and K. Czarnecki
Conference NameGCSE’2000 Workshop on C++ Template Programming
Date Published10/2000
Conference LocationErfurt, Germany

Mixin-Based Programming in C++ is a powerful programming style based
on the parameterized inheritance idiom and the composition of C++
templates. Type expressions describing specific inheritance
hierarchies can be composed either automatically using generative
programming idioms in C++ or manually. Unfortunately, the mixin-based
C++ programming techniques published to date do not adequately support
optional and alternative mixin classes with constructors expecting
varying numbers of arguments, which are common in practice. This is
because the varying base class constructors do not provide a uniform
interface on which the constructors of the derived classes could rely.
This paper discusses several partial solutions to this problem that
were proposed to date and presents a new, complete solution. The new
solution uses generative programming techniques to automatically
generate the appropriate constructors, and this way it avoids the
overhead and clumsiness of instantiating composed mixin classes in the
client code using the partial solutions. In fact, the new solution
allows users to instantiate automatically composed mixin classes with
the simplicity of instantiating concrete classes from traditional
class hierarchies. Finally, the new solution does not suffer from the
scalability problems of the partial solutions.

Refereed DesignationRefereed