This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [v3] tr1::array fixups


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();"


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]