Arrays template arguments and CT data structures

bearophile bearophileHUGS at lycos.com
Fri Oct 2 17:41:44 PDT 2009


language_fan:

> Note 
> that if the data structures are small, generating them takes very little 
> time on modern 32/64-bit hardware. OTOH if you have tens of megabytes of 
> binary data in your .exe, hard drives are a serious bottleneck.

You forget an important thing: If you generate things at compile time the compiler is more able to optimize the code, because more data is available at compile time (it can be a form of "partial specialization").

---------------------

Tom S:

> What do you mean by that? So parametrizing a template with a static 
> array would cause less bloat than doing so with a tuple? I guess you 
> might shave off a few bytes if mangling was shorter, but except that? *gasp*

Tuples seems composed of dynamically typed items at compile time, so an array may need less memory to be managed by the compiler because its items have all the same type.

And regarding the binary bloat, I was thinking about the "static foreach" over tuples, that has inflated some of my programs. But this isn't a real problem, so please breath normally :-)

Bye and thank you,
bearophile



More information about the Digitalmars-d mailing list