[Issue 16222] template failed to infer/coerce types for instantiation
via Digitalmars-d-bugs
digitalmars-d-bugs at puremagic.com
Thu Jun 30 05:54:19 PDT 2016
https://issues.dlang.org/show_bug.cgi?id=16222
--- Comment #2 from Ketmar Dark <ketmar at ketmar.no-ip.org> ---
(In reply to ag0aep6g from comment #1)
> In your example, you could of course just take a const(char)[] directly,
> without any template parameters. So that isn't a good motivating example to
> change the behavior.
this is common pattern in my code, actually. i want my functions to accept
`string`, `const(char)[]` and `char[]` seamlessly, yet they should not do
unnecessary dups when i need to copy value. that is, there is no need to dup
`string` (obviously), but it's better to dup `char[]` and `const(char)[]`.
without template, i can't tell if `string` or `const(char)[]` was passed.
i was so sure that compiler does conversion of `null` to empty slice that
didn't even checked it beforehand. and today i was caught by the first case.
--
More information about the Digitalmars-d-bugs
mailing list