On Friday, 4 November 2016 at 17:37:10 UTC, Basile B. wrote:

Hello, I'm not sure that's exactly what you want but check this:

============================
template A(As...) {
    template B(Bs...) {
    }
}

alias BI = A!(1,2).B!(3,4,5);

import std.traits;

template NestedTemplateArgsOf(alias T)
{
alias NestedTemplateArgsOf = TemplateArgsOf!(__traits(parent, T));
}

alias Bs = TemplateArgsOf!BI;
alias As = NestedTemplateArgsOf!BI;


static if (is(typeof(BI) == typeof(A!As.B!Bs)))
{
    pragma(msg, "for the win");
}
============================

The missing key was NestedTemplateArgsOf. With it you can solve the problem.

Well, kind of. But i think i can make it with what i got from your example, so thanks. Another thing that I encountered and while messing with your code is that __traits( parent, T ) does not work as expected when you have structs instead of template. I think because something like

struct A(As...) {}

is downgraded to

template A(As...) {
  struct A {}
}

when i use __traits( parent, A!(1,2) ) i get in return A!(1,2), looping around the same symbol.
When you compile this

struct A(As...) {}

import std.conv;

pragma( msg, "The parent symbol is the same? " ~ to!string( __traits( isSame, A!(1,2), __traits( parent, A!(1,2) ) ) ) );

void main() {}

you get a really interesting result:

The parent symbol is the same? true

Gianni Pisetta

Reply via email to