http://stackoverflow.com/questions/17724479/in-d-how-do-i-specify-a-variadic-template-constraint-on-all-the-whole-tuple

Posted on stackoverflow first since I think it's better for the language to get traction there. For completeness sake, posting the text of the question here as well:



I'm writing 2 overloads of a function, both of them with variadic template compile-time parameters. One should take symbols as the templates, the other strings. I want to constrain the template instantiation to these two cases. The best I came up with was this:

bool func(SYMBOLS...)() if(!is(typeof(SYMBOLS[0]) == string)) {
}

and

bool func(STRINGS...)() if(is(typeof(STRINGS[0]) == string)) {
}

Obviously this only checks the first template parameter, and while it works given the code I've written so far, I wish I could say "only for all strings" and "only for not all strings". Is there a way?

Thanks in advance.

Reply via email to