Checking a (base) type and accepting any specialization?

monkyyy crazymonkyyy at gmail.com
Sun Jun 8 16:36:48 UTC 2025


On Sunday, 8 June 2025 at 16:33:08 UTC, monkyyy wrote:
>
> the most correct answer is nested templates
> ```d
> template foo(T){
> struct foo(T data){
>   ...
> }}
> ```
> You can probably find an api workaround in ctfe with 
> `assert(__ctfe)` to make it work better; but when all else 
> fails this ends up being nessery(most cant read even simple 
> ones tho)
> ---
> madness and compile bugs:
> `struct foo(T, T data)` will work *once*, your names a little 
> new for me to attempt to explain why
> ---
> you should probably just use an alias:
> ```d
> struct Routine(alias argscount = 1) {
> 	alias T=typeof(argscount);
> 	T[argscount] data;
> }
> unittest{
> 	Routine!(ubyte(2)) foo;
> 	Routine!3 bar;
> }
> ```



More information about the Digitalmars-d-learn mailing list