Template constructor instantiation syntax remains unresolved
James Blachly
james.blachly at gmail.com
Sun Jan 27 01:22:09 UTC 2019
I ran in to this bug from 2013 tonight:
https://issues.dlang.org/show_bug.cgi?id=10689
Briefly, templated (and overloaded) constructor syntax is
supported:
this(int MAX_UNPACK = BCF_UN_ALL, T)(T *h, bcf1_t *b)
if(is(T == VCFHeader) || is(T == bcf_hdr_t))
{
...
}
this(SS)(VCFHeader *vcfhdr, string chrom, int pos, string id,
string _ref, string alt, float qual, SS filter, )
if (isSomeString!SS || is(SS == string[]))
{
...
}
this(int MAX_UNPACK = BCF_UN_ALL)(VCFHeader *vcfhdr, string
line)
{
...
}
But there is no way (?) to instantiate these with specific
template value parameters. (Deduction works just fine)
auto rr = new VCFRecord!BCF_UN_STR(vw.vcfhdr, "...");
for example, returns the same error it did in 2013:
Error: template instance `VCFRecord!BCF_UN_STR` VCFRecord is not
a template declaration, it is a class
Suggestions given in past threads include templating the class,
but in this, and other posters' examples, the constructor is
overloaded with several ways to construct the object. Too, I am
not sure how templating the class would work with template value
parameters (vice type params).
Given that templating the constructor is well-supported
syntactically, the suggestion to use a factory function seems
inelegant.
Thanks for listening and suggestions.
James
More information about the Digitalmars-d
mailing list