Get the latest tech news

C++26 Contracts: Introduction to Preconditions and Postconditions


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.

None

Get the Android app

Or read this on Hacker News

Read more on:

Photo of contracts

contracts

Photo of introduction

introduction

Photo of preconditions

preconditions

Related news:

News photo

Anthropic and Microsoft Dominate Nscale’s $103 Billion in Contracts

News photo

'The introduction of AI is an accelerator, not a replacement for packaged applications': Oracle bets on AI to strengthen customer ROI

News photo

Intel BFF Driver Slated For Linux 7.4 Introduction