className

Returns the dynamic class name of an Object or an interface.

string
className
(
bool assumeDemangled = true
T
)
(
T t
)
if (
is(T == class) ||
is(T == interface)
)

Parameters

assumeDemangled

Must only be set to false if the class is declared in a unittest.

t
Type: T

Either an interface or a class instance.

Examples

1 static interface I {}
2 static class A{}
3 static class B: I{}
4 static class C{}
5 assert(className(new A) == "A");
6 assert(className(new B) == "B");
7 assert(className(cast(Object)new A) == "A");
8 assert(className(cast(Object)new B) == "B");
9 assert(className(cast(I) new B) == "B");
10 assert(className!(false)(new C) == "C");

Meta