digitalmars.D.bugs - [Issue 19180] New: Expose dmd.mtype.Type.isZeroInit as
- d-bugmail puremagic.com (27/27) Aug 19 2018 https://issues.dlang.org/show_bug.cgi?id=19180
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 puremagic.com Reporter: n8sh.secondary 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 --
Aug 19 2018