Ah, simple solution to unittests inside templates

Andrei Alexandrescu via Digitalmars-d digitalmars-d at puremagic.com
Sun Sep 18 05:14:47 PDT 2016


On 9/18/16 6:00 AM, Jonathan M Davis via Digitalmars-d wrote:
> Yes. That's DIP 82:
>
> http://wiki.dlang.org/DIP82
>
> I need to go over it again and then introduce it into the new DIP process.
> But I really think that that's where we should go to fix this problem.

Just a thought: things that we can't do have high priority. Things that 
we can do with a modest cost are much less attractive. Consider:

struct Awesome(A, B, C)
{
     private enum ut = is(A == int) && is(B == int) && is(C == int);

     static if (ut) unittest
     {
         ...
     }
}

You're looking at an overhead with a small fixed cost plus a few 
characters ("if (ut)") per unittest.


Andrei



More information about the Digitalmars-d mailing list