It’s pretty common to implement graphs in terms of arrays, not because of indices but because of cache locality.
So your “UB” and “non-UB” code would look effectively identical to the CPU and would take the same amount of debugging.
The reality is whether an index was tombstones and referenced or “deallocated” and referenced it is still a programmer fault that is a bug that the compiler could not catch
So your “UB” and “non-UB” code would look effectively identical to the CPU and would take the same amount of debugging.
The reality is whether an index was tombstones and referenced or “deallocated” and referenced it is still a programmer fault that is a bug that the compiler could not catch