
Larry Evans <cppljevans@cox-internet.com> writes:
On 06/03/2005 02:47 PM, David Abrahams wrote:
Neal Becker <ndbecker2@gmail.com> 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?
Yep. -- Dave Abrahams Boost Consulting www.boost-consulting.com