static map as a type function

Paul Backus snarwin at gmail.com
Thu Sep 24 02:42:00 UTC 2020


On Thursday, 24 September 2020 at 02:09:31 UTC, Jackel wrote:
>
> It's basically what D is to C++ template metaprogramming.
>
> Compare the staticMap implementation with a type function 
> implementation and it's pretty clear which one is more readable 
> and easier to maintain. The current D implementation will also 
> create a bunch of template bloat with numerous instantiations 
> that aren't actually required.
>
> StaticMap, and many other templates like it also need a 
> workaround to reduce the number of instances, otherwise they 
> fail. Which isn't as intuitive and not something someone will 
> really know to do.

On the other hand, if you can fix recursive template bloat 
somehow (tail-call elimination?), you get good performance *and* 
nice code. It's the best of both worlds.


More information about the Digitalmars-d mailing list