On Thursday, 28 January 2016 at 17:32:31 UTC, Gary Willoughby
wrote:
On Thursday, 28 January 2016 at 15:10:38 UTC, Adam D. Ruppe
wrote:
On Thursday, 28 January 2016 at 13:36:46 UTC, Puming wrote:
I searched the forum and found that people use
`const(char)[]` or `in char[]` to accept both string and
char[] arguments.
There's also the hyper-generic signatures Phobos uses like
void foo(S)(S s) if(isSomeString!S)
Yep, this is your answer.
void foo(S)(S s) if(isSomeString!S)
{
//use s
}
Call normally as it can implicitly determine the type of S:
foo("bar");
Template bloat awaits those who take this approach to every
problem. In practice, `in char[]` is probably better for most
code.