Interesting uses of mixin template 'injection'.

SealabJaster sealabjaster at gmail.com
Thu Dec 24 06:04:45 UTC 2020


While working on some code recently, I realised that it's 
possible for mixin templates to be passed into a templated type, 
which is then mixed into that type.

e.g.:

```
mixin template T()
{
    void* p;
    ~this(){ freeIfNotNull(p); }
    @disable this(this){}
}

struct S(alias T)
{
    mixin T;
}

alias ST = S!T;
```

I'm starting to find the possible potential of this kind of 
interesting, and was just wondering if anyone knows any existing 
uses of passing mixin templates like this, as I'd love to get 
some ideas flowing.


More information about the Digitalmars-d mailing list