r/cpp • • Feb 26 '26

The Joy of C++26 Contracts - Myths, Misconceptions & Defensive Programming - Herb Sutter

https://www.youtube.com/watch?v=oitYvDe4nps&t=1s
72 Upvotes

84 comments sorted by

View all comments

Show parent comment

21

u/38thTimesACharm Feb 26 '26

Is it really that hard to imagine why a language feature would be preferred to a preprocessor macro? You could say that about every feature then.

14

u/James20k P2005R0 Feb 26 '26

The issue isn't that its a language feature, its that contracts have many downsides over using a macro. If it isn't better than the thing it replaces, it won't replace it in many codebases and we'll be stuck in macro-land with another vestigial feature