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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T03:10:05+00:00 2026-05-11T03:10:05+00:00

I have a map defined like this std::map<some_key_type, std::string::iterator> mIteratorMap; And a huge string

  • 0

I have a map defined like this

std::map<some_key_type, std::string::iterator> mIteratorMap; 

And a huge string named ‘mHugeString’. Then I walk trough the string collecting iterators like this:

std::string::iterator It=mHugeString.begin(); std::string::iterator EndIt=mHugeString.end(); for(;It!=EndIt;++It){   ...defining a key element...   if(need_to_store_an_iterator)mIteratorMap[key_of_a_right_type]=It; } 

In the end I should recieve a map, where an iterator is associated with a some sort of key. But the iterator somehow looses itself when being paired with a key by ‘make_pair’, unless it points to a place somewhere in the end of a string. It’s hard to tell, but maybe last 256 bytes are fine.

So the question is not how to avoid loosing iterators, it was a stupid idea to store them anyways, but why trying to store an iterator in the begining of the string fails, and why the same with the iterators on the end works fine? What is the difference between them?

  • 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. 2026-05-11T03:10:06+00:00Added an answer on May 11, 2026 at 3:10 am

    I haven’t tried it but I would have expected that, of course you can store iterator values as values in a map.

    Do you know that if you change the contents of mHugeString then any iterators into it which you have previously stored are now invalid?

    You might choose to store the index into the string, instead of the iterator.

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

Sidebar

Ask A Question

Stats

  • Questions 142k
  • Answers 142k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Actually, using the Databinder syntax in your templates is a… May 12, 2026 at 8:20 am
  • Editorial Team
    Editorial Team added an answer This question has been asked and answered a few times… May 12, 2026 at 8:20 am
  • Editorial Team
    Editorial Team added an answer preg_match_all: $str = '/srv/www/site.com/htdocs/system/application/views/'; preg_match_all('/\/([^\/]+)/', $str, $matches); // $matches[0] contains… May 12, 2026 at 8:20 am

Related Questions

I have a std::map declared thusly in a legacy MFC application: typedef std::map<long, CNutrientInfo>
I'm writing some template classes for parseing some text data files, and as such
I have a 'foreach' macro I use frequently in C++ that works for most
I have a join function that operates on STL strings. I want to be

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.