2009/5/16 Sebastian Redl
Or, even simpler, how do I do this?
size_t strnlen(char *p, size_t n) { return find(p, p+n, '\0') - p; }
That's the size of a range, but I don't know how to get that range.
You don't. Null-terminated strings, in Alexei's model, are ranges that have a fixed end point, which you can't modify. (There is no representation in the range for it.) You basically have to reinterpret the nts as an array with a known end-point, so you can treat it as a random access range. Now, for an rar, getting that range is easy.
That's why I used strnlen, not plain old strlen. I have a range(p, p+n), which is a full random-access, has_size, etc range. All I want to do is get the range before the first '\0'. The specific interpretation isn't the point. If you prefer, consider the case on tokenizing a string, where I want the range before the first space. It's the same problem.