Example:
module foo.bar;
class C
{
this() { x = 10; }
int x;
}
void main()
{
auto c = cast(C)factory!(foo.bar)("C");
assert(c !is null && c.x == 10);
}Object factory(alias mod)(string classname)Create instance of class specified by the module symbol and a string representing the name of the class. The class must either have no constructors or have a default constructor.
mod | symbol representing the module that the class is in |
classname | string representing the name of the class |
Example:
module foo.bar;
class C
{
this() { x = 10; }
int x;
}
void main()
{
auto c = cast(C)factory!(foo.bar)("C");
assert(c !is null && c.x == 10);
}