r/cpp • u/antiquark2 #define private public • Feb 24 '26
P4019R0: constant_assert (Jonas Persson)
https://www.open-std.org/JTC1/SC22/WG21/docs/papers/2026/p4019r0.pdf
23
Upvotes
r/cpp • u/antiquark2 #define private public • Feb 24 '26
View all comments
Show parent comment
1
u/cd_fr91400 Feb 25 '26
I think you missed the point.
The purpose is not to check that x is not modified, it is to guarantee that the loop will eventually end, which requires x to be negative.
The purpose here is to guarantee this at compile time : if x is not known to be negative at compile time, then fire up.
I say this is the goal because there are valid objections mentioned in other comments about the effectiveness of this check.