Consider that some $mixins are defined (the implementations are not shown):
$mixin M1<typename T> { [implementation] };
$mixin M2 { [implementation] };
$mixin M3 { [implementation] };
$mixin M4 { [implementation] };
In the following example, the mixin chain of class C
refers to the ordered list of mixins
[M1<int> M2 M3 M4 M1<float> M3]
.
$class C mixin [M1<int> M2 M3 M4 M1<float> M3] {};
Note that a given mixin can appear more than once in a mixin chain.
[M1<int> M2 M3 M4 M1<float> M3]
can be regarded as a convenient shorthand
for M3<M1<float,M4<M3<M2<M1<int,Base<C>>>>>>>
,
where Base<C>
is some system defined template class instantiated with C
that "seeds" the mixin chain.
The final class C
is passed into the base of the mixin chain to implicitly support the
curiously recurring template pattern for each mixin in the chain.
A mixin can itself declare that it inherits from a mixin chain. For example
$mixin M5 mixin [M1<char> M2] {};
A mixin chain can directly contain anonymous mixins.