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 6217411
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T07:25:20+00:00 2026-05-24T07:25:20+00:00

If I use a default constructor for an iterator, how to check if it

  • 0

If I use a default constructor for an iterator, how to check if it was assigned later on?

For pointers, I could do this :

int *p = NULL;
/// some code
if ( NULL == p ) {
  // do stuff
}

How do I do the above for iterators?
Is it possible at all?

#include <iostream>
#include <list>

int main ()
{
    std::list<int>::iterator it;

  if ( NULL == it ) // this fails
  {
      std::cout<<"do stuff" << std::endl;
  }
}
  • 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-24T07:25:20+00:00Added an answer on May 24, 2026 at 7:25 am

    I managed to find this in the current standard (c++03 ). 24.1 p 5 tells :

    Just as a regular pointer to an array guarantees that there is a
    pointer value pointing past the last element of the array, so for any
    iterator type there is an iterator value that points past the last
    element of a corresponding container. These values are called
    past-the-end values. Values of an iterator i for which the expression
    *i is defined are called dereferenceable. The library never assumes
    that past-the-end values are dereferenceable. Iterators can also have
    singular values that are not associated with any container.
    [Example:
    After the declaration of an uninitialized pointer x (as with int* x;),
    x must always be assumed to have a singular value of a pointer. ]
    Results of most expressions are undefined for singular values; the
    only exception is an assignment of a non-singular value to an iterator
    that holds a singular value.
    In this case the singular value is
    overwritten the same way as any other value. Dereferenceable values
    are always non- singular.

    (Emphasis mine)

    So the answer is : no, it is not possible.

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

Sidebar

Related Questions

Can I use default arguments in a constructor like this maybe Soldier(int entyID, int
Is it better to use default null or default for text fields in MySQL?
At my company we use the default agile process template with some modificiations. One
When I provide a constructor with a default value public MyClass(string description = null)
Is it possible to use named arguments in a Scala constructor, and later on
The thing is, I am not (knowing trying to use any default constructor of
I use this code pattern all over and only in this particular property an
Why is it harmful to use TranscationScope 's default constructor? Can someone point me
Is it possible to configure Hiberate/NHibernate not to use the default constructor to create
As we use default keyword as a access specifier, and it can be used

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.