Strings and Slices

Steven Schveighoffer schveiguy at gmail.com
Sat Feb 20 19:39:38 UTC 2021


On 2/20/21 2:31 PM, Mike Brown wrote:
> On Saturday, 20 February 2021 at 19:28:00 UTC, Mike Brown wrote:
>> On Thursday, 18 February 2021 at 21:08:45 UTC, Adam D. Ruppe wrote:
>>> [...]
>>
>> Thank you. Is there a standardised type to make "mark"? size_t or is a 
>> normal integer suitable?
> 
> Ah, and whats the recommended way to iterate over a slice using a mark? 
> Can I get the current iteration point from a foreach loop?

ints work as slice endpoints just fine. They will get cast to size_t 
when used for slicing.

If you are going to keep the mark valid, you shouldn't slice away the 
input, because now 0 becomes the point at the mark.

Typically with slices, you don't store a position (sometimes), you just 
divvy up the slice into pieces you care about.

It all depends on what information is important.

-Steve


More information about the Digitalmars-d-learn mailing list