[Issue 9514] "template instance … is not an alias"

d-bugmail at puremagic.com d-bugmail at puremagic.com
Fri Feb 15 14:21:03 PST 2013


http://d.puremagic.com/issues/show_bug.cgi?id=9514



--- Comment #4 from Walter Bright <bugzilla at digitalmars.com> 2013-02-15 14:21:01 PST ---
So far, I've reduced it to:
------------------------------

import std.typetuple : TypeTuple;

template TStructHelpers() {
    alias typeof(this) This;

    bool opEquals(This ) {
    thriftOpEqualsImpl;
    }

    bool thriftOpEqualsImpl() {
    foreach (name; FieldNames!This)
        return ;
    }
}


struct Foo {
    mixin TStructHelpers!();
}

template memberReq(T, string name, alias fieldMetaData = cast()null) {
    enum memberReq = memberReqImpl!(T, name, fieldMetaData);
}

import std.algorithm : find;

template memberReqImpl(T, string name, alias fieldMetaData) {
    enum meta = find!`a.name == b`;
}

template notIgnored(T, string name= null) {
    enum notIgnored = memberReq!(T, name) ;
}

template FieldNames(T, alias fieldMetaData = cast()null) {
    StaticFilter!(
    All!(
    PApply!(),
    PApply!(notIgnored, T)
    )) FieldNames;
}

template StaticFilter(alias pred) {
    static if (pred!()) TypeTuple!() StaticFilter;
}

template PApply()
{
    alias void PApply;
}

template PApply(alias Target, T...) {
template PApply() {
Target!(PApplyMergeArgs!(ConfinedTuple!T).Result) PApply;
}
}

template PApplyMergeArgs(alias Preset) {
alias TypeTuple!(Preset.Tuple) Result;
}

template Instantiate(alias Template, Params...) {
Template!Params Instantiate;
}

template All(T...) {
template All() {
Instantiate!(T[1 .. $])All;
}
}

template ConfinedTuple(T...) {
alias T Tuple;
}

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list