How to get the name of an object's class at compile time?

Steven Schveighoffer schveiguy at gmail.com
Mon Feb 17 18:49:55 UTC 2020


On 2/17/20 2:28 AM, Nathan S. wrote:
> What I want is something like this:
> 
> ----
> string className(in Object obj) {
>      return obj is null ? "null" : typeid(obj).name;
> }
> ----
> 
> ...except I want it to work in CTFE. What is the way to do this in D?

https://issues.dlang.org/show_bug.cgi?id=7147

It's not doable. It really should be.

-Steve


More information about the Digitalmars-d-learn mailing list