class template as a type
Frits van Bommel
fvbommel at REMwOVExCAPSs.nl
Wed Sep 19 02:27:51 PDT 2007
Karl wrote:
> BCS Wrote:
>
>> void Foo(Test!(somthingToAlias) { }
>> static Test!(somthingToAlias)[] myarray;
>>
>> look for "Explicit Template Instantiation" in
>>
>> http://www.digitalmars.com/d/template.html
>
> "somthingToAlias" could be anything right? Lets suppose foo.bar1 or foo.bar2. Then "static Test!(foo.bar1)[] myarray;" would create an array only for elements instantiated from foo.bar1 and i couldn't append an element instantiated from foo.bar2, am i wrong?
>
> 1) Then how could i create an array for generic instantiated elements?
You could give your template class a non-templated base function, and
use that as the type of the array elements.
> 2) "void Foo(Test!(somthingToAlias) { }", i think something is missing:
>
> - ")".
Yes, he seems to have made a typo there
> - A variable name, (correct me if wrong): void Foo(Test!(somthingToAlias) sta){ }
Technically the name is optional, but it does come in quite handy when
you actually want to *use* the parameter in the function body :).
More information about the Digitalmars-d-learn
mailing list