On Saturday, 5 November 2016 at 14:37:53 UTC, Basile B. wrote:
On Saturday, 5 November 2016 at 13:34:51 UTC, Gianni Pisetta wrote:
[...]

Indeed, I've been fighting against that since a few minutes. We cant select the Base of an eponymous template.


template isEponymousTemplate(T)
{
static if (is(T == class) || is(T == interface) || is(T == struct) || is(T == union))
    {
        enum p = __traits(parent, T).stringof == T.stringof;
        enum isEponymousTemplate = p && isTemplateInstance!T;
    }
    else
        enum isEponymousTemplate = false;
}

template TemplateBase(T : Base!Args, alias Base, Args...)
if (is(T == class) || is(T == interface) || is(T == struct) || is(T == union))
{
    alias TemplateBase = Base;
}

To be more accurate the template base can be selected for

    template A(T) {class A{}}

but not for

    class A(T){}

Reply via email to