Issue with char and string overlap
monarch_dodra
monarchdodra at gmail.com
Fri Jul 19 10:46:33 PDT 2013
On Friday, 19 July 2013 at 17:25:34 UTC, JS wrote:
> BTW, I'd like to have a default value for d. That or efficiently
> allow for variadic d, which then the default delim could easily
> be tested for.
To answer your previous question about shadowing, you are
probably experiencing an old bug where you can't overload a
template and non-template. This was fixed in HEAD, but is not yet
available in a packaged version (eg, it is not in 2.063.2).
The standard workaround is declaring your function as a
"parameter-less parameterized function (!)"
string[] split()(string s, string d); //This is actually a
template.
If you want d to be variadic, while still having a default case,
any number of solutions are available, including simply doing
this:
string[] split()(string s); (1*)
string[] split(Args...)(string s, Args args); (2)
(1) is "more specialized" (I think), so will be considered the
better match for "split("hello")". IF I'm wrong, simply add "if
(Args.length > 0)" as a template restriction for the second
function, and you are good to go.
If you have access to head, then declare (1) as a straight up
function. In that case, it most certainly *will* be the better
match.
More information about the Digitalmars-d-learn
mailing list