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: [email protected]
Reporter: [email protected]
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
---
--