February 26, 2020 [Issue 20614] New: CTFE supports typid(stuff).name but not classinfo.name | ||||
|---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=20614 Issue ID: 20614 Summary: CTFE supports typid(stuff).name but not classinfo.name Product: D Version: D2 Hardware: All OS: All Status: NEW Keywords: CTFE Severity: enhancement Priority: P1 Component: dmd Assignee: nobody@puremagic.com Reporter: b2.temp@gmx.com This commit https://github.com/dlang/dmd/pull/10796, adds support for retireving the dynamic class name at compile time. but it only works with typeid and not classinfo, which should be supported too since therey are the same thing. --- string classname(Object o) { return typeid(o).name; } string classnameAlt(Object o) { return o.classinfo.name; } class Panzer {} class Tiger : Panzer {} static assert (() { Panzer p = new Tiger(); return classname(p); } () == "Tiger"); // OK static assert (() { Panzer p = new Tiger(); return classnameAlt(p); } () == "Tiger"); // NG --- -- | ||||
Copyright © 1999-2021 by the D Language Foundation
Permalink
Reply