[Issue 14735] [REG2.068-b1] std.string.indexOf cannot deduce function for char argument
via Digitalmars-d-bugs
digitalmars-d-bugs at puremagic.com
Sat Jun 27 02:57:32 PDT 2015
https://issues.dlang.org/show_bug.cgi?id=14735
--- Comment #4 from Mike <slavo5150 at yahoo.com> ---
The problem has something to do with the CaseSensitive argument.
This (cut-and-paste code compiles):
//*********************************
import std.stdio;
import std.traits;
import std.range.primitives;
import std.typecons : Flag;
alias CaseSensitive = Flag!"caseSensitive";
ptrdiff_t indexOf(Range)(Range s, in dchar c)
if (isInputRange!Range && isSomeChar!(ElementEncodingType!Range))
{
return 0;
}
ptrdiff_t indexOf(Range)(Range s, in dchar c, in size_t startIdx)
if (isInputRange!Range && isSomeChar!(ElementEncodingType!Range))
{
return 0;
}
ptrdiff_t indexOf(Range, Char)(Range s, const(Char)[] sub)
if (isForwardRange!Range && isSomeChar!(ElementEncodingType!Range) &&
isSomeChar!Char)
{
return 0;
}
ptrdiff_t indexOf(T, size_t n)(ref T[n] s, in dchar c)
if (isSomeChar!T)
{
return indexOf(s[], c);
}
ptrdiff_t indexOf(Char1, Char2)(const(Char1)[] s, const(Char2)[] sub, in size_t
startIdx)
if (isSomeChar!Char1 && isSomeChar!Char2)
{
return 0;
}
void main()
{
char[10] fixedSizeArray = "0123456789";
assert(indexOf(fixedSizeArray, '2') == 2);
assert(indexOf(fixedSizeArray[], '2') == 2); // Issue 14735
}
This code does not compile. The only difference is the addition of the
CaseSensitive argument.
//***********************************
import std.stdio;
import std.traits;
import std.range.primitives;
import std.typecons : Flag;
alias CaseSensitive = Flag!"caseSensitive";
ptrdiff_t indexOf(Range)(Range s, in dchar c, in CaseSensitive cs =
CaseSensitive.yes)
if (isInputRange!Range && isSomeChar!(ElementEncodingType!Range))
{
return 0;
}
ptrdiff_t indexOf(Range)(Range s, in dchar c, in size_t startIdx, in
CaseSensitive cs = CaseSensitive.yes)
if (isInputRange!Range && isSomeChar!(ElementEncodingType!Range))
{
return 0;
}
ptrdiff_t indexOf(Range, Char)(Range s, const(Char)[] sub, in CaseSensitive cs
= CaseSensitive.yes)
if (isForwardRange!Range && isSomeChar!(ElementEncodingType!Range) &&
isSomeChar!Char)
{
return 0;
}
ptrdiff_t indexOf(T, size_t n)(ref T[n] s, in dchar c, in CaseSensitive cs =
CaseSensitive.yes)
if (isSomeChar!T)
{
return indexOf(s[], c);
}
ptrdiff_t indexOf(Char1, Char2)(const(Char1)[] s, const(Char2)[] sub, in size_t
startIdx,
in CaseSensitive cs = CaseSensitive.yes)
if (isSomeChar!Char1 && isSomeChar!Char2)
{
return 0;
}
void main()
{
char[10] fixedSizeArray = "0123456789";
assert(indexOf(fixedSizeArray, '2') == 2);
assert(indexOf(fixedSizeArray[], '2') == 2); // Issue 14735
}
I'm still not sure how to fix this, but I hope this information is helpful.
--
More information about the Digitalmars-d-bugs
mailing list