Boost logo

Boost Users :

Subject: Re: [Boost-users] iterators must go
From: Scott McMurray (me22.ca+boost_at_[hidden])
Date: 2009-05-17 21:39:19


2009/5/16 Sebastian Redl <sebastian.redl_at_[hidden]>:
>
>> 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.


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net