Determine if a type if derived from a template parameter
Alex
sascha.orlov at gmail.com
Thu Apr 11 06:36:14 UTC 2019
On Wednesday, 10 April 2019 at 23:13:48 UTC, Alex wrote:
>
> Another hypothetical: Suppose one wanted to rebuild the class X
> above, when one reflected to get the members, it would be
> impossible to know which parameter was used for x, if any
> because traits will return, say, int.
>
I tried something similar a while ago:
https://forum.dlang.org/post/yithkynlyqnejalezixy@forum.dlang.org
What I ended up with is:
I put the content of the part to rebuild into a (parametrized)
mixin template. And at each place, where I wanted to rebuild this
part I mixed it in.
Pro: the mixin template forces me to provide checked template
parameter
Con: I tried to factorize the parts by hand and it wasn't very
convenient. At the very end, I needed it in too few places, to
continue to pursue this strategy...
More information about the Digitalmars-d
mailing list