Unqualified class name

Jeremy T. Gibson jtgibson at telus.net
Sat Aug 21 17:33:51 UTC 2021


I saw this thread -- 
https://forum.dlang.org/post/hdkvezicxfvehbtvjkfu@forum.dlang.org 
-- which works at compile time (although templating seems like 
overkill for my purpose), but is there a simple way to get the 
unqualified name of a class at runtime without having to pass it 
through std.format?  `typeid(class).name` always yields the full 
classname, including its module information (i.e., 
"modulename.classname"), where I only want "classname" on its own.

I'm currently using manually-assigned literals to store the name 
of each class, which seems... wrong. ;-)

If it matters or makes things simpler, the class is attempting to 
report its own name in one of its own methods, rather than an 
external function attempting to deduce the name of an arbitrary 
object at runtime.


More information about the Digitalmars-d-learn mailing list