How to pass voldemort types to functions

Ali Çehreli via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Fri Jun 12 15:53:53 PDT 2015


On 06/12/2015 03:46 PM, kerdemdemir wrote:

 >> void foo(R)(R range)
 >>     if (isInstanceOf!(Tuple, ElementType!R))    // <-- optional
 >> {

 > I am also happy to learn optional static if .

Actually, it is not 'static if' but a template constraint. It is 
optional because everything will work without it.

If you call it with a range where elements are not Tuples and the 
function really requires that they are (e.g. the function does not 
compile if it is not Tuple), then the location of the error message will 
be different:

a) With template constraint the caller is in error

b) Without template constraint the function is in error

Ali



More information about the Digitalmars-d-learn mailing list