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
You can have this for any values, but C++ doesn't provide it. WUFFS is an obvious example of what you'd do in this direction, using refinement typing so that it knows OK, this index must be
0 <= k < lengthand if it can't see why that's true from the code (including your mathematical annotations) then that won't compile, so as a result there's no need to do bounds checks at runtime.