synthesising instantiated template parameters and arguments

Nicholas Wilson iamthewilsonator at hotmail.com
Wed Oct 28 05:51:14 UTC 2020


Given

template ScopeClass(C)
{
     //...
}


where C is a, possibly templated, class I want the eponymous 
member of ScopeClass!(C) to have the same templatedness (both 
parameters and arguments)as C.
For a non-template C this is a simple as:

template ScopeClass(C)
{
     class ScopeClass
     {
          // implement members with compile time reflection
     }
}

but for a templated C this is tricker as I can't use a template 
sequence parameter (...) unless C uses it in the same position 
(I'm trying to generate a mangle from it so it needs to be 
exact). Given

class A(T,int,args...) {}
alias C = A!(int, 0, float);

I need `ScopeClass!C` to be

template ScopeClass(C)
{
     class Anon(T,int,args...) // name doesn't matter
     {
          // implement members with compile time reflection
     }

     alias ScopeClass = Anon!(int, 0, float);
}

How do I do this?


More information about the Digitalmars-d-learn mailing list