How to get compatible symbol names and runtime typeid names for templated classes?

cc cc at nevernet.com
Tue May 3 09:42:45 UTC 2022


This produces compatible strings between symbol and runtime type:
```d
class Foo {}
void main() {
	alias Foo F;
	writeln(fullyQualifiedName!F);
	auto f = new F;
	writeln(typeid(f).name);
}
```
```
test.Foo
test.Foo
```

But if the class is a template, the strings different:
```d
class Foo(bool b) {}
void main() {
	alias Foo!true F;
	writeln(fullyQualifiedName!F);
	auto f = new F;
	writeln(typeid(f).name);
}
```
```
test.Foo!(true)
test.Foo!true.Foo
```

Given a runtime typeid, how can I get the equivalent 
fullyQualifiedName without attempting to mangle the string myself 
manually?  e.g. something I can pass to `Object.factory`.


More information about the Digitalmars-d-learn mailing list