Inferring function argument types from other argument types

Joseph Rushton Wakeling joseph.wakeling at webdrake.net
Mon Nov 12 05:13:41 PST 2012


On 11/12/2012 02:02 PM, bearophile wrote:
> Like this?

Thanks for the thought, but not really :-(  Your code _checks_ that the second 
argument has the correct type, but it doesn't perform an implicit conversion 
where that is possible.

In a pseudo-code-y sense, what I want to be able to do is something like:

     auto func(FooT)(FooT foo, FooT.T1 x)
     {
         ...
     }

and indeed I tried that on the off-chance that it'd work; but it fails to 
compile with an error message "Undefined identifier FooT.T1".

All of the messing around with a second template argument was just in order to 
be able to achieve something equivalent to the above.


More information about the Digitalmars-d-learn mailing list