[Issue 19180] New: Expose dmd.mtype.Type.isZeroInit as __traits(isZeroInit, T)
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Mon Aug 20 01:38:15 UTC 2018
https://issues.dlang.org/show_bug.cgi?id=19180
Issue ID: 19180
Summary: Expose dmd.mtype.Type.isZeroInit as
__traits(isZeroInit, T)
Product: D
Version: D2
Hardware: All
OS: All
Status: NEW
Severity: enhancement
Priority: P1
Component: dmd
Assignee: nobody at puremagic.com
Reporter: n8sh.secondary at hotmail.com
It's useful to identify at compile time types with 0 initializers. Doing this
with CTFE and templates is slow and memory-hungry[1] and runs into
errors[2][3]. The compiler already has its own check for this that we can
expose instead.
Proposed syntax is `__traits(isZeroInit, T)` where the second argument must
resolve to the type T itself instead of being any expression whose result is an
instance of T. This would be to prevent someone from mistakenly thinking he can
use `__traits(isInitZero, x)` to test whether some variable `x` was explicitly
initialized as zero.
[1] https://github.com/dlang/phobos/pull/6537
[2] https://github.com/dlang/phobos/pull/6670#issuecomment-414111649
[3] https://github.com/dlang/phobos/pull/6461
--
More information about the Digitalmars-d-bugs
mailing list