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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T04:35:45+00:00 2026-06-18T04:35:45+00:00

Given a particular stl collection in C++, is the end() value equivalent for all

  • 0

Given a particular stl collection in C++, is the end() value equivalent for all instances of the same templatization? In other words, will the following work for all stl containers and circumstances (not just for std::map)?

std::map<Key, Value> foo(int seed);

std::map<Key, Value> instance1 = foo(1);
std::map<Key, Value> instance2 = foo(2);
std::map<Key, Value>::iterator itr = instance1.begin();
std::map<Key, Value>::iterator endItr = instance2.end(); // Comes from other collection!

for (; itr != endItr; ++itr) {
  // Do something on each key value pair...
}
  • 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-06-18T04:35:47+00:00Added an answer on June 18, 2026 at 4:35 am

    No, because of the STL container and iterator requirements:

    23.2.1 General container requirements [container.requirements.general]

    6 begin() returns an iterator referring to the first element in the
    container. end() returns an iterator which is the past-the-end value
    for the container. If the container is empty, then begin() == end();

    24.2.1 In general [iterator.requirements.general]

    6 An iterator j is called reachable from an iterator i if and only if
    there is a finite sequence of applications of the expression ++i that
    makes i == j. If j is reachable from i, they refer to elements of the
    same sequence.

    The equality of begin() and end() for empty containers means that begin() and end() need to be part of the same container objects, and hence end() cannot be a static member of a container class. Note also that -except for forward iterators- applying operator-- on end() would be impossible to resolve with a static end() iterator.

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

Sidebar

Related Questions

I have given the particular permission for the particular user. Only that menu will
I've been given a stack of data where a particular value has been collected
I tried to check the given value is contained or not in particular field.
I want to, when given a particular model, return all the related models it
Given a particular URL, how do I find out for sure which controller action
given a traceback error log, i don't always know how to catch a particular
In my controller i had given [ValidateInput(false)] for that particular Action in my return
I've heard that given a programmer with enough time and skill in any particular
I wrote this script which counts occurrences of particular pattern in a given file.
I want to measure API evolution for a given Java project, in particular new/renamed

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.