Re: Why does vector.end() point beyond last element?

From: Gianni Mariani (gi2nospam_at_mariani.ws)
Date: 06/27/04


Date: 26 Jun 2004 21:36:44 EDT

as mellow as a horse wrote:
> You'll probably guess I'm only just learning this stuff so this might be a
> stupid question. Given:
>
...
> Why does b1.end() point 1 memory location past the 4th element?

Because it does !

Some may argue that it makes the applications easier to write.
i.e.

for ( i = begin(); i != end(); ++i )
{
        .. stuff with i ..
}

it also makes it easy to detect an empty list...

is_empty = begin() == end();

   I was
> getting rubbish until I had a brainwave and tried some fiddly pointer
> arithmetic. Am I missing something?

No.



Relevant Pages

  • Re: Stirring up My Plate: Seasons Goals
    ... scores--come directly from the quality of the performance, and learning to the level of the horse is a long process when one has a good school master. ... But it cannot survive treason from within. ... But the traitor moves amongst those within the gate freely, his sly whispers rustling through all the alleys, heard in the very halls of government itself. ...
    (rec.equestrian)
  • Re: Excellent TV Piece on GA
    ... there are those who view flying with a similar apathy. ... learning to ride a horse. ... check on three other projects in-progress. ...
    (rec.aviation.piloting)
  • Re: Standing still: the basis of all training (was: Re: Settlingin/horsey nerves)
    ... I don't think he knows what a mounting block is. ... >> My horse is weak in this area, and I have never been able to get through ... > with anticipation of the next event. ... > He sighed and became mellow. ...
    (rec.equestrian)
  • Re: Im not enjoying my lessons anymore....
    ... It sounds like the only skill she is learning ... are forced to concentrate on to the exclusion of learning all other skills ... Although, I've gotta admit, after eight years of schoolies, it's nice ...
    (rec.equestrian)
  • Re: SCI Is Completely Dead Now Isnt It.
    ... my alabaster buttocks. ... learning to ride a horse. ... We all make our own reality at the end of the day. ... forget the only time I ever sat on a horse. ...
    (soc.culture.irish)