c++ what's the result of iterator + integer when past-end-iterator?

前端 未结 5 2002
生来不讨喜
生来不讨喜 2021-01-13 02:28

suppose you have a random access iterator (eg of std::vector myVector)

when iter + someInt is past-end-iterator, iter + someInt == my

5条回答
  •  时光说笑
    2021-01-13 03:05

    It's Undefined Behavior. Anything may happen. Just to name a few of the options: Nothing at all, program exits, exception, crash.

提交回复
热议问题