Non-recursive maxSizeOf

Per Nordlöw per.nordlow at gmail.com
Thu Aug 6 01:23:33 UTC 2020


On Thursday, 6 August 2020 at 01:13:41 UTC, Adam D. Ruppe wrote:
> It is very easy too... just write an ordinary function:
>
> size_t maxSizeOf(T...)() {
>         size_t max = 0;
>         foreach(t; T)
>                 if(t.sizeof > max)
>                         max = t.sizeof;
>         return max;
> }
>
> pragma(msg, maxSizeOf!(int, char, long));

How does the memory usage and speed of this code compare to the 
variant that uses template instantiations? In general? Any 
experiences on this?


More information about the Digitalmars-d-learn mailing list