Currently there are no traits to extract default initializers out of an aggregate type. For example: ----- struct S { int x = 1; int y = 0; int z; } ----- There is a workaround: Use S.init to retrieve default values. However, it is not reliable. Because S.init == S(1, 0, 0), but in fact 'z' does not have a *user-provided* initializer, it only has an initializer due to T.init. This distinction is important for things like Configuration structures. I propose a simple API: __traits(hasInitializer, ...). Then, it can be composed with fairly simply: static if (__traits(hasInitializer, S.x)) doSomething(S.init.x); static if (!__traits(hasInitializer, S.z)) doSomethingElse();
This is overkill and can easily be worked around with UDAs.