How to Instantiate struct defined in template
Jonathan M Davis
jmdavisProg at gmx.com
Sat Sep 22 21:52:16 PDT 2012
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
More information about the Digitalmars-d-learn
mailing list