On Sunday, 8 June 2025 at 14:29:27 UTC, mitgedanken wrote:
I have following situation:

I have a struct ``Routine`` (base type) and its specializations ``!n``.

```d
struct Routine (uint argscount = 1) {
    string name;
    void delegate(inout Arguments!argscount) return call;
}

const auto ROUTINES = [
    Routine!3(":input", toDelegate(&routine_input)),
    Routine!2(":print", toDelegate(&routine_print)),
];
```

I understand why the given types are not compatible.
But not how I can store any base type regardless its specialization.

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;
}
```

Reply via email to