How to Instantiate struct defined in template

Craig Dillabaugh cdillaba at cg.scs.carleton.ca
Sat Sep 22 22:01:59 PDT 2012


On Sunday, 23 September 2012 at 04:51:31 UTC, Jonathan M Davis
wrote:
> On Sunday, September 23, 2012 06:37:30 Craig Dillabaugh wrote:
>> One question. Is there any way to get the function template to
>> deduce the type of T from the vertices I pass, so that I can
>> call:
>> 
>> euclid_dist(v1, v2) )
>> 
>> instead of:
>> 
>> euclid_dist!float(v1, v2) );
>
> It should infer the types just fine as-is. Templated functions 
> can pretty much
> always infer the template arguments from their function 
> arguments. It's with
> types that that doesn't work (so a constructor requires 
> template arguments,
> but a function does not).
>
> - Jonathan M Davis

Yes, you are right. I thought I had tried it without the !float
and it hadn't worked, but I guess not.

Thanks again for all your help.
Craig


More information about the Digitalmars-d-learn mailing list