Real naive template question

WhatMeForget via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sun Aug 13 17:44:05 PDT 2017


module block_template;

void main()
{
     template BluePrint(T, U)
     {
         T integer;
         U floatingPoint;
     }

     BluePrint!(int, float);
}

// DMD returns
// template.d(13): Error: BluePrint!(int, float) has no effect

// I was expecting something like the following to be created 
after compilation:

module block_template;

void main()
{
     {
         int integer;
         float floatingPoint;
     }
}


I realize this is a corner case, but shouldn't the 
BluePrint!(int, float); statement blindly create a block of code?



More information about the Digitalmars-d-learn mailing list