Dummy template parameter vs empty template parameter list

Seb seb at wilzba.ch
Wed Apr 10 21:40:22 UTC 2019


On Wednesday, 10 April 2019 at 20:37:38 UTC, Ben Jones wrote:
> Looking through Phobos code there's a bunch functions defined 
> with dummy template types:
>
> void whatever(TDummy = void)( int x, ...) //TDummy is never used
>
> Why not just use an empty template parameter list?
>
> void whatever()(int x, ...)
>
>
> My gut tells me that his is a workaround for an old limitation 
> preventing empty template lists, but figured I'd ask.

It depends on the specific function, but there's lots of old code 
in Phobos. In this case it could be that it was a workaround for 
a DMD bug or limitation that has since been fixed.

So never be afraid to question Phobos code and give it the full 
scrutiny it needs.

A good rule of thumb is that if all unittests still pass, the 
reason was historic ;-)


More information about the Digitalmars-d-learn mailing list