How can I test at compile time whether T is an instance of an interface ?
data pulverizer
data.pulverizer at gmail.com
Wed Sep 23 20:29:35 UTC 2020
On Wednesday, 23 September 2020 at 20:19:04 UTC, data pulverizer
wrote:
> This has prompted me to write a data structure that I thought
> would be impossible until now. [...SNIP...]
Here is the function with the correct template constraint:
```
auto makeChain(Args...)(Args args)
if(Args.length > 2 && is(Args[0] == Start) && is(Args[Args.length
- 1] == End))
{
args[0].next = args[1];
static foreach(i; 1..(Args.length - 1))
{
args[i].prev = args[i - 1];
args[i].next = args[i + 1];
}
args[$ - 1].prev = args[$ - 2];
return args[0];
}
```
More information about the Digitalmars-d-learn
mailing list