mixin template's alias parameter ... ignored ?

Ali Çehreli acehreli at yahoo.com
Sun Jul 11 05:54:48 UTC 2021


On 7/10/21 10:20 PM, someone wrote:

 > mixin template templateUGC (
 >     typeStringUTF,
 >     alias lstrStructureID
 >     ) {
 >
 >     public struct lstrStructureID {

The only way that I know is to take a string parameter and use it with a 
string mixin:

mixin template templateUGC (
    typeStringUTF,
    string lstrStructureID
    ) {

   mixin("public struct " ~ lstrStructureID ~ q{
       {
         typeStringUTF whatever;

       }
     });

}

mixin templateUGC!(string,  "gudtUGC08");
mixin templateUGC!(dstring, "gudtUGC16");
mixin templateUGC!(wstring, "gudtUGC32");

void main() {

    gudtUGC32 something;

}

Ali



More information about the Digitalmars-d-learn mailing list