Ah, simple solution to unittests inside templates

Jonathan M Davis via Digitalmars-d digitalmars-d at puremagic.com
Sun Sep 18 13:52:41 PDT 2016


On Sunday, September 18, 2016 13:10:36 Jonathan M Davis via Digitalmars-d 
wrote:
> On Sunday, September 18, 2016 08:02:47 Andrei Alexandrescu via Digitalmars-d
> wrote:
> > On 9/17/16 5:23 PM, Andrej Mitrovic wrote:
> > > I think at some point someone suggested we could implement explicit
> >
> > > support for such unittests via `static unittest`:
> > That suggests the unittest shall be evaluated during compilation. --
> > Andrei
>
> How so? At this point, static as a keyword pretty much never means that
> something is compile-time specific.

Actually, static does mean compile-time in the case of static assert, so
there is at least once case where it does, but most uses of static mean
something else, and you have to know the context to know what the static
keyword means. I selected static, because this use case fit reasonably well
with how it was used with constructors, and it didn't require a new keyword
or attribute. But the word static itself isn't the important part. It's the
feature, and something else could be used. static just seemed like a good
fit. That can be discussed with the DIP though whenever it gets resubmitted
and reviewed.

- Jonathan M Davis



More information about the Digitalmars-d mailing list