Checking if a function exists

Michiel nomail at please.com
Wed Feb 21 14:08:16 PST 2007


Max Samukha wrote:

>> For all types you can use T.init as the dummy value to the function (I just remembered its existence).
> 
> This works for module scope functions:
> 
> static if (is(typeof(&.toString) == char[] function(T))) // '.' is the
> module scope operator or use fully qualified name. Trickier ways might
> exist.

That doesn't work if there are multiple overloads of the same function,
like with toString. I just tested it.

Tyler's method worked, though.

Thanks!

-- 
Michiel



More information about the Digitalmars-d mailing list