Non-recursive maxSizeOf

Steven Schveighoffer schveiguy at gmail.com
Thu Aug 6 13:51:07 UTC 2020


On 8/6/20 9:23 AM, Adam D. Ruppe wrote:
> On Thursday, 6 August 2020 at 13:18:40 UTC, Per Nordlöw wrote:
>>                 mixin(T.stringof ~ " _store" ~ T.mangleof ~
> 
> Never ever use mixin(T.stringof). Always just use mixin("T") instead.
> 
> mixin("T _store", T.mangleof /* or just idx is gonna be better */,";");
> 
> Though I doubt this is going to win a benchmark anyway getting this 
> complicated.

Well, one *could* do:

static if(is(union { Ts t; }))

and use the union for "normal" cases.

I think the CTFE solution is cleaner. Is there a good reason to avoid it?

-Steve


More information about the Digitalmars-d-learn mailing list