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

I'm learning JavaScript and while browsing through the jQuery library I see : (colon)
I have been learning to use Emacs for a little while now. So far
While learning different languages, I've often seen objects allocated on the fly, most often
I've been learning python for a while now with some success. I even managed
While going through university and from following the development of SO, I've heard a
While learning Haskell I had the feeling that the authors where not always telling
While learning C I regularly come across resources which recommend that some functions (e.g.
While learning about creating MS SQL Reporting and deploying reports to SQL Reporting Server,
While learning Perl I am also learning Linux (Ubuntu), so it is kinda fire-hose
While learning on anonymous methods, i've found the following example on the internet: namespace

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.