logoalt Hacker News

AlotOfReading • today at 3:19 AM • 1 reply • view on HN

You'll find plenty of info if you search for anything like "c++ contracts" [0], but the short of it is that they're just pre/post conditions on functions. Slightly improved assertions, basically.

[0] https://en.cppreference.com/cpp/language/contracts


Replies

btown • today at 3:48 AM

https://www.cppstories.com/2026/cpp26_contracts/ is IMO a better introduction.

cppreference is often a bit too technical for its own good :)

But I think there's a broader issue which is that if it took me multiple searches to find a good-enough visual "pitch" for what contracts look like in practice, its champions have not yet won hearts and minds - which brings us to the situation at hand.

➕ show 1 reply