Unqualified class name

Ali Çehreli acehreli at yahoo.com
Sat Aug 21 18:27:34 UTC 2021


On 8/21/21 10:33 AM, Jeremy T. Gibson wrote:

> `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've been reminded of __traits(identifier) on this forum just yesterday:

import std.stdio;

class Coo {

   string name() const {
     return __traits(identifier, typeof(this));
   }
}

void main() {
   auto c = new Coo();
   writeln(c.name());
}

Ali


More information about the Digitalmars-d-learn mailing list