CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 15 of 20

Threaded View

  1. #5
    Join Date
    Apr 1999
    Posts
    27,449

    Re: Setting an iterator to "end"

    Quote Originally Posted by potatoCode
    Hello mybowlcut,

    change your logical operator to
    Code:
     for(; it < camera_tiles.end(); ++it)
    No.

    The correction is this:
    Code:
     for(; it != camera_tiles.end(); ++it)
    The end() of a sequence can be any value that the implementor of the container class has created. The only guarantee is that when you increment past the end of the valid items in a container, the iterator is equal to end().

    The real correction to MyBowlCut's code is to not mess around with (in other words change) the controlling loop iterator in the middle of the loop. Any code that I see doing that is always susceptible to some sort of bug.

    Regards,

    Pauil McKenzie
    Last edited by Paul McKenzie; August 9th, 2008 at 07:12 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured