Template constructor in a non-template struct.
via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Mon Feb 9 01:52:12 PST 2015
On Sunday, 8 February 2015 at 22:19:35 UTC, ChrisG wrote:
> Thanks bearophile. Your first suggestion about making the
> struct a template is something I considered. However, because
> of all the code I've already written that approach would force
> me to use inheritance or convert a ton of functions to
> templates. Ick.
>
> The __ctor syntax looks like the answer to my question. If my
> struct is used by anyone else though, I'm not sure it would be
> OK to assume they would even be aware of that syntax. hmmm...
> Thinking I'll just make it a runtime parameter for now.
>
You could also hide the ugly __ctor() call behind a nicely named
factory method.
More information about the Digitalmars-d-learn
mailing list