|
Boost Users : |
Subject: Re: [Boost-users] iterators must go
From: Sebastian Redl (sebastian.redl_at_[hidden])
Date: 2009-05-16 07:31:22
Scott McMurray wrote:
> On Fri, May 15, 2009 at 17:15, Daniel James <daniel_james_at_[hidden]> wrote:
>
>> The relevant point is that bringToFront's first range can step over
>> the second range.
>>
>>
>
> I'm very curious how that's supposed to work. What if, for example,
> the second range is a superset of the first? Or, since they can be
> two different types, what happens if I do the same thing as the above,
> but "retro" one or both of the ranges? It just sounds brittle to me.
>
> 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.
Sebastian
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