y3c-stl 0.3.3
Friendly C++ STL wrapper with automatic stacktrace
Loading...
Searching...
No Matches
vector-iter-reallocate.cc

‍example output:

y3c-stl terminated: undefined behavior detected (ub_access_deleted)
at y3c::vector<int>::iterator::operator*(): attempted to access the deleted value.
Stack trace (most recent call first):
#0 0x000055a82d55572e in main at /home/runner/work/y3c-stl/y3c-stl/build/../examples/vector-iter-reallocate.cc:8:18
6: y3c::vector<int>::iterator it = a.begin();
7: a.resize(100);
8: std::cout << *it << std::endl;
9: }
reference operator*() const
Definition iterator.h:119
Definition array.h:8
#include <y3c/vector>
#include <iostream>
int main() {
y3c::vector<int> a = {1, 2, 3, 4, 5};
a.resize(100);
std::cout << *it << std::endl;
}
array, vector など各種コンテナのイテレータ
Definition iterator.h:26
可変長配列 (std::vector)
Definition vector.h:23
void resize(size_type count)
サイズを変更
Definition vector.h:499
iterator begin()
先頭要素を指すイテレータを取得
Definition vector.h:673