[v3] tr1::array fixups

Sashan Govender sashang@gmail.com
Sat Oct 16 20:34:00 GMT 2004


On Sat, 16 Oct 2004 20:23:19 +0200, Paolo Carlini <pcarlini@suse.de> wrote:
> Benjamin Kosnik wrote:
> 
> >        const_iterator
> >        end() const
> >!       { return reinterpret_cast<iterator>(&_M_instance[_S_index - 1]); }
> >
> By the way, a few days ago, I have noticed that end() - beg() == size()
> - 1 != size(),
> I think this is not ok: end() should point one-past-end, as always
> happens with the
> other containers...
> 
> Wouldn't be better just using (_M_instance + _S_index) ??
> 
> Paolo.
> 

Yeah - I agree that it should point to one past the end since that is
how other container types behave. I checked the C++ standard
[lib.container.requirements] and it has this to say

"begin() returns an iterator referring to the first element in the
container. end() returns an iterator which is the past-the-end value
for the container. If the container is empty, then begin() == end();"



More information about the Libstdc++ mailing list