Movatterモバイル変換


[0]ホーム

URL:


D Logo
Menu
Search

Library Reference

version 2.112.0

overview

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 usinga 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:
modsymbol representing the module that the class is in
stringclassnamestring representing the name of the class
Returns:
null if failed

Example

module foo.bar;class C{this() { x = 10; }int x;}void main(){auto c =cast(C)factory!(foo.bar)("C");assert(c !isnull && c.x == 10);}

Copyright © 1999-2026 by theD Language Foundation | Page generated byDdoc on Sat Feb 21 00:05:17 2026

[8]ページ先頭

©2009-2026 Movatter.jp