Template function that accept strings and array of strings

badlink via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Thu Jul 16 09:49:47 PDT 2015


Thank you for all answers.

Removing typeof do resolve the problem when the second parameter 
is a simple string.
However when passing an array of string the error still occur:
Error: template cache.MetadataCache.hasItemParent cannot deduce 
function from argument types !()(string, string[]).

The method with the variadic function works, but I would have to 
use only one parameter because this doesn't work:
fun(const(char[])[] a, const(char[])[] b ...)
and is a bit ugly in my use case ...

After some tests I found that:
if (is(T == char) || is(T == string))
works, so I assume the problem is the immutable nature of string 
that breaks the type checking.

What should I use to enable this function to accept all 
combinations char[], const(char)[], and immutable(char) ?




More information about the Digitalmars-d-learn mailing list