Is my T.init elaborate (eg: Not "0")

monarch_dodra via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Mon May 5 13:54:51 PDT 2014


I'm looking for a way, to *statically* know if my type's ".init" 
value is nothing but zeros.

I need this to initialize a dynamic array: If the T.init is 
nothing but 0, then I can just memset the whole array in a single 
call. Otherwise, I have to memcpy T.init individually N times.

Currently, I can (runtime) use "typeid(T).init.ptr": Types that 
don't have an an elaborate .init will return null.

I'm trying to find the same result, without a runtime check. 
Anybody know how? I'd write a function that tests the bits of a 
T.init copy, but reinterpreting is not allowed during CTFE...


More information about the Digitalmars-d-learn mailing list