The worst Phobos template (in binderoo)

Stefan Koch via Digitalmars-d digitalmars-d at puremagic.com
Thu Sep 15 06:27:42 PDT 2016


On Thursday, 15 September 2016 at 13:20:16 UTC, Andrei 
Alexandrescu wrote:
> On 09/15/2016 08:35 AM, Stefan Koch wrote:
>> On Thursday, 15 September 2016 at 12:26:08 UTC, Andrei 
>> Alexandrescu wrote:
>>>
>>> Apparently we need that static foreach iteration. -- Andrei
>>
>> What exactly do you mean ?
>> As long as we instanciate n templates for a member nested n 
>> levels the
>> overhead is massive!
>> How would static foreach help ?
>
> I thought staticMap is just a (simulated) loop that applies the 
> same template in sequence. -- Andrei

staticMap is a recursive variadic template.
CompileTime wise the worst class a template can be in.
it expands to a series of templates instancing itself log(n) 
times.
causing 2n*log(n) instances in total.

It's not a pretty picture.


More information about the Digitalmars-d mailing list