r/cpp • u/pavel_v • Jul 29 '26
C++26: Reducing undefined behaviour
https://www.sandordargo.com/blog/2026/07/29/cpp26-reduces-undefined-behaviour
89
Upvotes
r/cpp • u/pavel_v • Jul 29 '26
View all comments
Show parent comment
0
u/tialaramex Jul 30 '26
In C this is true.
vec[k]is*(vec+k)but in C++operator[]can be overridden so maybe it's not a pointer dereference at all. And indeed bothstd::arrayandstd::vectordo override this operator (though of course in the unhardened C++ they in fact are still both just pointer dereferences).