Re: Trying to alias this a grapheme range + making it a forward range

2019-07-09 Thread aliak via Digitalmars-d-learn
On Monday, 8 July 2019 at 23:01:49 UTC, ag0aep6g wrote: On 08.07.19 23:55, aliak wrote: [...] `source.front` is a temporary `Grapheme` and you're calling `opSlice` on it. The documentation for `Grapheme.opSlice` warns: "Invalidates when this Grapheme leaves the scope, attempts to use it

Re: Trying to alias this a grapheme range + making it a forward range

2019-07-08 Thread ag0aep6g via Digitalmars-d-learn
On 08.07.19 23:55, aliak wrote: struct ustring {     string data;     this(string data) {     this.data = data;     }     auto get() {     static struct Range {     typeof(string.init.byGrapheme) source;     bool empty() { return source.empty; }     void

Trying to alias this a grapheme range + making it a forward range

2019-07-08 Thread aliak via Digitalmars-d-learn
Problem 1: I'm trying to get a string to behave as a .byGrapheme range by default, but I can't figure out Grapheme. I'm trying to replicate this behavior: foreach (g; "hello".byGrapheme) { write(g[]); } In a custom type: struct ustring { string data; this(string data) {