Jump to content
  • Advertisement
Sign in to follow this  

STL setting iterator outside container

This topic is 5205 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi guys, I've got one quick, easy-to answer, and probably also stupid question for you: Can I set iterator to point on element that is not inside any container? Consider this code:

typedef std :: map < CFG_String, CFG_Internal_Group> CFG_Internal_GroupMap;

typedef CFG_Internal_GroupMap :: iterator CFG_Internal_GroupMapItor;

struct CFG_Internal_File
  CFG_Internal_GroupMap groups;
  CFG_Internal_GroupMapItor selected_group;
  /* Variable: global_group

   Global group is not stored in map,
   because we would have to reserve some kind of ID for global group name.
   Instead, we store it direcly in struct, treating it differently also in other ways.
  CFG_Internal_Group global_group;

I would like to use selected_group as a pointer/iterator to: 1. sometimes one of the groups in groups field 2. sometimes to global_group Is it possible to do it in C++? I'm afraid not... but I want to be sure. Using iterator instead of pointer would probably help in managing those groups in other parts of code. What do you say? It's late here, and google hasn't helped... probably because it's such stupid question nobody has ever asked it :-/ Thanks in advance for help.

Share this post

Link to post
Share on other sites
Ok, thx for help :-) I also thought that it's not possible, but just wanted to be 100% sure.

For me it's EOT.

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!