Factory pattern in D
Namespace via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Fri May 1 03:04:44 PDT 2015
How about this:
----
struct A {
int x = 42;
}
struct B {
int x = 7;
}
T factory(T)() {
return T();
}
void main()
{
auto a = factory!(A);
}
----
More information about the Digitalmars-d-learn
mailing list