Jump to content

Recommended Posts

Posted

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();

sSet.erase(itr);

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.

Posted

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.

-edit-

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...

×
×
  • 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