이터레이터의 무효화 규칙
2018. 3. 27. 22:10
https://stackoverflow.com/questions/6438086/iterator-invalidation-rules
C++03 (Source: Iterator Invalidation Rules (C++03))
Insertion
Sequence containers
vector
: all iterators and references before the point of insertion are unaffected, unless the new container size is greater than the previous capacity (in which case all iterators and references are invalidated) [23.2.4.3/1]deque
: all iterators and references are invalidated, unless the inserted member is at an end (front or back) of the deque (in which case all iterators are invalidated, but references to elements are unaffected) [23.2.1.3/1]list
: all iterators and references unaffected [23.2.2.3/1]
Associative containers
[multi]{set,map}
: all iterators and references unaffected [23.1.2/8]
Container adaptors
stack
: inherited from underlying containerqueue
: inherited from underlying containerpriority_queue
: inherited from underlying container
Erasure
Sequence containers
vector
: every iterator and reference after the point of erase is invalidated [23.2.4.3/3]deque
: all iterators and references are invalidated, unless the erased members are at an end (front or back) of the deque (in which case only iterators and references to the erased members are invalidated) [23.2.1.3/4]list
: only the iterators and references to the erased element is invalidated [23.2.2.3/3]
Associative containers
[multi]{set,map}
: only iterators and references to the erased elements are invalidated [23.1.2/8]
Container adaptors
stack
: inherited from underlying containerqueue
: inherited from underlying containerpriority_queue
: inherited from underlying container
Resizing
vector
: as per insert/erase [23.2.4.2/6]deque
: as per insert/erase [23.2.1.2/1]list
: as per insert/erase [23.2.2.2/1]
'프로그래밍 > C, C++ 공부' 카테고리의 다른 글
__stdcall 과 __cdecl (0) | 2018.04.03 |
---|---|
emplace_back과 push_back 의 차이 (0) | 2018.03.28 |
오늘 주의깊게 본 스택오버플로우 (0) | 2018.03.22 |
static에 대한 공부 (0) | 2018.03.17 |
기본 생성자, 복사 생성자, 복사 대입자 그리고 암시적 형변환과 explicit (0) | 2018.03.17 |