std.uni.CodepointSet from range of pairs of integers

Carl Sturtivant sturtivant at gmail.com
Mon Feb 19 01:32:47 UTC 2024


I wanted to construct a CodepointSet from a string, so I used the 
constructor here.
https://dlang.org/phobos/std_uni.html#.InversionList.this.2

I wrote a range of pairs (CodepointIntervals) of integers 
consisting of each codepoint in the string paired with that plus 
one. This did solve the problem, but only after I overcame some 
peculiarities of the situation.

Specifically, this required a forward range, not just an input 
range, so I wrote a save method.

Once I fixed that problem, it needed empty() and popFront() to be 
pure. So I added the word pure to each in my range.

Once I fixed that problem, it required those to be @safe, so I 
added that to my struct declaration of my range.

Then everything worked.

Could I have anticipated any of this, and what is the reason for 
each of these?




More information about the Digitalmars-d-learn mailing list