On Fri, 27 May 2011 21:29:10 +0300, KennyTM~ <[email protected]> wrote:
On May 28, 11 02:05, Vladimir Panteleev wrote:
Why hasLength!string is false:
https://github.com/D-Programming-Language/phobos/blob/96941d5384a5fee302df/std/range.d#L767
Would it make sense to introduce a hasOpaqueLength oslt. to fix this?
You mean std.array.join? The 2-argument overload has specialization for
strings
(https://github.com/D-Programming-Language/phobos/blob/master/std/array.d#L966).
static if (isForwardRange!RoR && hasLength!RoR
&& (hasLength!(ElementType!RoR) ||
isSomeString!(ElementType!RoR))
// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
&& hasLength!R)
It doesn't exist for the 1-argument overload though.
Thanks! But it looks like the 2-argument overload is broken too. It
doesn't check if the separator is a string, so that branch isn't taken for
join(string[], string). In fact, it doesn't work at all when the second
argument is an iterator with length:
C:\Soft\dmd2\src\phobos\std\array.d(778): Error: template
std.algorithm.copy(Range1,Range2) if (isInputRange!(Range1) &&
isOutputRange!(Range2,ElementType!(Range1))) does not match any function
template declaration
C:\Soft\dmd2\src\phobos\std\array.d(778): Error: template
std.algorithm.copy(Range1,Range2) if (isInputRange!(Range1) &&
isOutputRange!(Range2,ElementType!(Range1))) cannot deduce template
function from argument types !()(Result,string)
test26.d(9): Error: template instance
std.array.join!(string[],Map!(result,string)) error instantiating
Program:
import std.array;
import std.algorithm;
void main()
{
string[] arr;
string sep;
join(arr, map!"a"(sep));
}
--
Best regards,
Vladimir mailto:[email protected]