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 p

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) {

Re: Using output-range overloads of SysTime.toISO{Ext}String with formatting code

2019-07-08 Thread Digital Mars via Digitalmars-d-learn
08.07.2019 13:38, Joseph Rushton Wakeling пишет: Thanks for taking the time to answer, but I don't think this really addresses my question. Your example shows a struct with `toString` overloads.  However, SysTime.toISOExtString does not work like this: it is a method with two explicit overl

Re: Using output-range overloads of SysTime.toISO{Ext}String with formatting code

2019-07-08 Thread Joseph Rushton Wakeling via Digitalmars-d-learn
On Sunday, 7 July 2019 at 20:12:30 UTC, drug wrote: 07.07.2019 17:49, Joseph Rushton Wakeling пишет: it's possible to do something like `writefln!"%s"(now.toISOExtString)` and have it automatically use the output range overload rather than allocating a new string instance. This is exactly ho