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

  • SEARCH
  • Home
  • 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 3598786
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T20:17:09+00:00 2026-05-18T20:17:09+00:00

In an algorithm I’m currently implementing, I need to manipulate a std::list of struct

  • 0

In an algorithm I’m currently implementing, I need to manipulate a std::list of struct T.
T holds a reference to another instance of T, but this reference can also be “unassigned”.
At first, I wanted to use a pointer to hold this reference, but using an iterator instead makes it easier to remove from the list.

My question is : how to represent the equivalent to null pointer with my iterator?

I read general solution is to use myList.end(), but in my case, I need to test whether the iterator is “null” or not, and I may add or remove elements to the list between the moment when I store the iterator and the moment I remove it from list… Should I make the iterator point to a known list containing the “null” element? Or is there a more elegant solution?

  • 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-18T20:17:10+00:00Added an answer on May 18, 2026 at 8:17 pm

    According to this (emphasis by me):

    Compared to the other base sequence
    containers (vector and deque), lists
    are the most efficient container doing
    insertions at some position other than
    the beginning or the end of the
    sequence, and, unlike in these, all of
    the previously obtained iterators and
    references remain valid after the
    insertion and refer to the same
    elements they were referring before.

    The same applies to erasure (with the obvious exception of iterators referring to a deleted element becoming invalidated). So yes, obtaining end() will always point to the same “invalid” element and should be safe to use.

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

Sidebar

Related Questions

I need a quick algorithm to select 5 random elements from a generic list.
I know the basic algorithm for this problem but I am having trouble changing
What algorithm to use to calculate a check digit for a list of digits?
What algorithm I can use for problem like this: Have a graph positive weighted,
In my algorithm, I need to create an information output. I need to write
i have a long algorithm that i need to put in a report. i
Algorithm Consider this layout: +-------------+ | | | | | +--+ | | |##|
My algorithm produces a list of (usually) several thousand line segments (all 2D) which
The algorithm I need to come up with is one that computes all the
I'm implementing am algorithm on C/C++ to process some vectors and I thought it

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.