Report a bug
		
				If you spot a problem with this page, click here to create a Bugzilla issue.
		
			Improve this page
		
			Quickly fork, edit online, and submit a pull request for this page.
			Requires a signed-in GitHub account. This works well for small changes.
			If you'd like to make larger changes you may want to consider using
			a local clone.
		
	core.factory
- Objectfactory(alias mod)(stringclassname);
- 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.Parameters:mod symbol representing the module that the class is in string classnamestring representing the name of the class Returns:null if failedExample 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); } 
Copyright © 1999-2025 by the D Language Foundation | Page generated by
Ddoc on Mon Mar 31 10:27:32 2025