by School-Cotton · 2y ago · 0 comments
Vector<int> v {1, 2, 3};
int *p = &v[0];
v.push_back(4);
printf("%d\n", *p); // this is UBBut yes, in my implementation I have a safe version of int called 'i32' which overrides the & operator and doesn't allow it to return raw pointers.
There are significant costs to this safety, of course, just like adding bounds checks.