Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3699004
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T05:03:01+00:00 2026-05-19T05:03:01+00:00

While learning c++ I went through the pains of learning what iterators were, and

  • 0

While learning c++ I went through the pains of learning what iterators were, and exactly how to use them. Then, I went through the pain of learning what function calls invalidate iterators, and spotting them quickly. I’ve been following questions lately and have noticed that a very common theme is people not realizing that calling vector::erase() invalidates iterators. This made me wonder if there were a debug implementation of vector that does runtime checking against vector valid-ness?

My initial thoughts were that it would have to be a wrapper around vector that basically tracked all existing iterators, and set an isValid boolean when an action was performed that invalidated them. Then, when dereferencing or incrementing, isValid could be checked.

This would help diagnose more obscure errors where the erase() call is nested (accidentally, or unknowingly) deep within a function call, while that same vector is being iterator over.

Does anyone know of such an implementation, or any reasons why one should not be used?

EDIT: I am using linux and g++.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-19T05:03:02+00:00Added an answer on May 19, 2026 at 5:03 am

    Microsoft’s implementation does some debug checking (ref, and ref). It checks specifically for range, so I’m not sure if the erase() scenario fits or not.

    Edit for jalf’s contribution:

    It appears that GCC (and g++) has similar functionality:

    stackoverflow.com/questions/2567997/ and

    gcc.gnu.org/onlinedocs/libstdc++/manual/debug_mode.html

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Cracking my head while learning MVC through MVC MusicStore . Got this error for
While learning to use LINQ in VB.NET, I came across the following: Dim x
I'm learning how to use python right now. I found a problem while learning
While learning Rails, I found this example in the Sam Ruby's book: app/controllers/line_items_controller.rb def
While learning an example from learn-you-a-haskell which right triangle that has integers for all
I am developing a small app while learning Android. The app is basically making
i just got some more questions while learning PHP, does php implement any built
MOV is probably the first instruction everyone learns while learning ASM. Just now I
I've slightly modified the iPhone SDK's GLSprite example while learning OpenGL ES and it
So I found some similarities between arrays and set notation while learning about sets

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.