Issue 10774 - std.range.indexed RangeError when indexing string with std.range.recurrence!"n"(0)
Summary: std.range.indexed RangeError when indexing string with std.range.recurrence!"...
Status: NEW
Alias: None
Product: D
Classification: Unclassified
Component: phobos (show other issues)
Version: D2
Hardware: All All
: P3 normal
Assignee: No Owner
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-08-07 13:51 UTC by Meta
Modified: 2024-12-01 16:18 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Meta 2013-08-07 13:51:29 UTC
import std.stdio;
import std.range;

void main()
{
	auto str = "石室詩士施氏,嗜獅,誓食十獅。"d;
	auto indStr = str.indexed(recurrence!"n"(0));

        //core.exception.RangeError@std.range(6177): Range violation
	writeln(indStr);
}


This code prints the string correctly, but it seems that it doesn't stop when the end of the string is reached.

石室詩士施氏,嗜獅,誓食十獅。
Comment 1 Meta 2013-08-07 14:05:20 UTC
Also, a workaround:

import std.utf;
import std.stdio;
import std.range;

void main()
{
    auto str = "石室詩士施氏,嗜獅,誓食十獅。"d;
    auto indStr = str.indexed(iota(str.count));
    writeln(indStr);

    readln();
}
Comment 2 dlangBugzillaToGithub 2024-12-01 16:18:35 UTC
THIS ISSUE HAS BEEN MOVED TO GITHUB

https://github.com/dlang/phobos/issues/9998

DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB