Jump to content



Recommended Posts

I have a question, when exactly to use const_iterator ?

Ive read its good to use only when you do not modify container as it wont be allowed, however;

I just managed to compile such code

std::set<ObjectGuid> sSet;

std::set<ObjectGuid>::const_iterator itr = sSet.begin();


Should be this disallowed by compilator ? (Same goes about list and all other containers)

Ah I found my answer:

Interestingly at least in N3092 for C++0x, containers' erase and insert methods indeed take const_iterator.

Can be closed / removed.

Link to comment
Share on other sites

Both gcc and MSVC have their own share of extensions enabled by default...including things from future standards aswell as from outdated standards or even times before the first official ISO C++ standard.

However, gcc is more aggressive at removing often abused things things, and more conservative about accepting future things by default, but the fact that gcc eats something is far from a verifying that it is written standard conform ;)

gcc has several options to be more or less strict, or to operate according to certain standards, like since 4.3 you can add -std=c++0x to use (more) feature from C++0x.

To my knowledge, erasing a const_iterator from STL container is according to the C++ standard currently in effect not possible.


btw. i did manage to commit something that gcc ate but MSVC didn't, and the standard was on Microsoft's side ^^ i just forgot what exactly it was...

Link to comment
Share on other sites


  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. Privacy Policy Terms of Use