Hacker News9h agoenergy 93

C++26 Contracts: Introduction to Preconditions and Postconditions

image: Hacker News

In the article about Standard Library hardening, we looked at checks for invalid Standard Library container access and other broken preconditions. I mentioned that those requirements are expressed in terms of “contracts”. But what about our code? In this post, we’ll explore contracts from C++26. We’ll start with a simple cassert, move the requirement into the function itself, and see how to check results.

read the original at Hacker News →
This source publishes only a summary in its feed, so the full article lives at the outlet. The link above and below goes to the original.