Boost logo

Boost :

From: David Abrahams (dave_at_[hidden])
Date: 2005-06-06 10:10:04

Larry Evans <cppljevans_at_[hidden]> writes:

> On 06/03/2005 02:47 PM, David Abrahams wrote:
>> Neal Becker <ndbecker2_at_[hidden]> writes:
>>>David Abrahams wrote:
> [snip]
>>>>B. What about the undefined behavior that results when you stride off
>>>> the end of a container?
>>>Is there any reasonable way to detect this? If it is feasible without
>>>significantly increasing cost, I'll add it - but offhand I don't know that
>>>it is generally feasible.
>> If it's random access you can store a base iterator and an index.
> ^^^^^
> Would "offset" be a better word? An index, i, to me, implies
> something satisfying:
> 0 <= i < shape[axis]
> where axis satisfies:
> 0 <= axis < rank
> where rank is the number of dimensions in the array and shape[axis] is
> the length of the axis-th dimension.

Sure, whatever.

> With this defintion, I understand what you mean, i.e. instead of
> the stride iterator incrementing the pointer, it would just store
> the beginning of the object:
> X* px0;
> and increment the offset. Then dereferencing would simply:
> return *(px0+offset);
> Is that you're meaning?


Dave Abrahams
Boost Consulting

Boost list run by bdawes at, gregod at, cpdaniel at, john at