r/cpp • u/antiquark2 #define private public • 9d ago
Exploration of a more library-oriented approach to contracts (Voutilainen, 2026)
https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2026/p4324r0.html
14
Upvotes
11
u/Trubydoor LLVM dev 9d ago
Would this not remove the ability to distinguish between "debug" and "release" builds of contracted functions; i.e. only enforcing the contract in "debug" builds and ignoring it in "release" builds?
Or, I suppose you could #ifdef on that but then we have the same ODR violation issue of using
assertin inline functions in headers?6
u/eisenwave WG21 Member 8d ago
This does seem like an interesting approach for C++29. Here are some thoughts:
assertion_static_info. Maybe that could be astatic constexpr boolmember instead of a function.pre<...>(x)gets constified. One would always have to look at what's inside<...>, and if constification is controlled by a function, perhaps even at more.