Inferring function argument types from other argument types

Vijay Nayar madric at gmail.com
Mon Nov 12 12:56:32 PST 2012


On Monday, 12 November 2012 at 18:53:21 UTC, Joseph Rushton 
Wakeling wrote:
> To be sure I understand your formulation, can you clarify the 
> meaning of is(FooT1 : FooType.T1)?

This means that the second parameter type, FooT1 must be of a 
type that is implicitly convertable to FooType.T1, if it is not, 
the template will not apply.  If no other templates exist, then 
you'll get a big error at compile time.

So unlike the earier solution posted on this thread, you do not 
need to create a variable of type size_t or cast the input to the 
function.  The value "4", of type int, will be accepted and cast 
to size_t automatically.

  - Vijay


More information about the Digitalmars-d-learn mailing list