Hi,

Can anybody tell me what I can assume when using iterator to set/map and performing --it when it is set to begin() of container ?
I've tested it and it seems that on set it works proper (it becomes end()), but on map it stays at begin() ..

Any comments anybody ? Is behavior in this case somehow specified or it depends on compiler ? And what about case when I have it pointing to end() ?

--
booleanx

  • created

    May '09
  • last reply

    May '09
  • 1

    reply

  • 104

    views

  • 2

    users

8 days later

The standards don't specify a behaviour if you decrement a begin iterator or increment an end iterator. In other words, the behaviour is undefined. Possibilities include: staying at begin(), changing to end(), giving an invalid iterator, throwing SIGABRT or something similar. Just don't do it.

Suggested Topics

Topic Category Replies Views Activity
C and C++ 0 35 26d

Want to read more? Browse other topics in C and C++ or view latest topics.