synthesising instantiated template parameters and arguments

Adam D. Ruppe destructionator at gmail.com
Wed Oct 28 18:29:58 UTC 2020


On Wednesday, 28 October 2020 at 05:51:14 UTC, Nicholas Wilson 
wrote:
> 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);
> }

So I'm not sure you can do what you want to do - D doesn't have 
any way to reflect on template parameters (though you CAN extract 
arguments I don't think it really helps here since you can't tell 
if the arguments were from `int, float` or from `T...` for 
example).

But like I don't really get why you need this. Can't you just use 
the arguments C already has and not have the extra layer? So 
you'd treat templated C the same was as non-templated C, and then 
if you want the mangle, just use like C.mangleof instead of 
trying to reconstruct it.

What's the bigger picture here?


More information about the Digitalmars-d-learn mailing list