On 08.04.2016 14:04, Voitech wrote:
template MixinTypeIterate(alias mixinTemplate,TList...){
[...]
}
how to alias mixin template to be able to pass it to this one ?

class BaseClass(T){
    protected alias Types=AliasSeq!(int,string,ubyte);
    private alias WrappedMix(S)=mixin Mix!(T,S); //not compiles - mixins
are no t regular templates

private mixin template WrappedMix(S) {mixin BaseMix!(T, S);}

Fixed a typo here: Mix -> BaseMix.

    mixin MixinTypeIterate!(WrappedImplMix,Types);
}
class ImplClass(T){
    private alias WrappedMix(T)=mixin ImplMix!(T,S); //not compiles -
mixins are no t regular templates

Ditto:

private mixin template WrappedMix(S) {mixin ImplMix!(T, S);}

Fixed another typo here: parameter T -> parameter S.

By the way, I find this very condensed style with no spaces around equals signs, after commas, or before braces quite hard to read.

    mixin MixinTypeIterate!(WrappedImplMix,Types);
}

Here's another thing that may be interesting to you. You can a have sequence of sequences by wrapping them in a non-eponymous template:

----
template Box(stuff ...) {alias contents = stuff;}

mixin template MixinTypeIterate(alias mixinTemplate, boxes ...)
{
    static if (boxes.length > 0)
    {
        mixin mixinTemplate!(boxes[0].contents);
        mixin MixinTypeIterate!(mixinTemplate, boxes[1..$]);
    }
}

mixin template simpleExample(T ...)
{
    void f(T args) {import std.stdio; writeln(args);}
}

mixin MixinTypeIterate!(simpleExample, Box!int, Box!(float, string));

void main()
{
    f(42);
    f(42.2, "foo");
}
----

Reply via email to