check instance of nested variadic template

Basile B. via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Fri Nov 4 10:37:10 PDT 2016


On Friday, 4 November 2016 at 15:50:36 UTC, Gianni Pisetta wrote:
> Hi all,
> I am having issues finding a solution for this, i want to check 
> if an alias is an istance of a variadic template nested in 
> another variadic template.
> [...]
> there is some sort of workaround?
>
> Thanks,
> Gianni

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.


More information about the Digitalmars-d-learn mailing list