How to get the constructor method of a class? -
i have class a
takes class b
template argument, , need b
's constructor in order (somewhat pseudocode):
class a(b) { import std.typecons : tuple; import std.traits : parameters; tuple!(parameters!b) _args; this(parameters!b args) { _args = args; } }
to store arguments constructor , later construct object of class b
arguments stored in _args
.
this pretty command pattern.
is there way constructor of b
parameters
? or there better way achieve deferred object construction?
yes, constructor's internal name __ctor
:
class c { this(int a, string b) { } } import std.traits; pragma(msg, parameters!(c.__ctor));
this outputs:
(int, string)
Comments
Post a Comment