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

‍example output:

y3c-stl terminated: undefined behavior detected (ub_access_deleted)
at y3c::wrap<int*>::operator*(): attempted to access the deleted value.
Stack trace (most recent call first):
#0 0x000055b025606718 in main at /home/runner/work/y3c-stl/y3c-stl/build/../examples/vector-ptr-reallocate.cc:8:18
6: y3c::ptr<int> p = &a[3];
7: a.resize(100);
8: std::cout << *p << std::endl;
9: }
値型wrap: base_type型のデータと、このデータの生存状態を管理するクラス
Definition wrap.h:26
Definition array.h:8
#include <y3c/vector>
#include <iostream>
int main() {
y3c::vector<int> a = {1, 2, 3, 4, 5};
y3c::ptr<int> p = &a[3];
a.resize(100);
std::cout << *p << std::endl;
}
可変長配列 (std::vector)
Definition vector.h:23
void resize(size_type count)
サイズを変更
Definition vector.h:499
ポインタ型wrap: element_type型のデータへのポインタと、 このポインタ自体の生存状態を管理するクラス
Definition wrap.h:318