C++ Logo

sg15

Advanced search

Re: [isocpp-sg15] P3835 -- Different contract checking for different libraries

From: Timur Doumler <cpp_at_[hidden]>
Date: Sun, 5 Oct 2025 23:32:01 +0300
Hi Andrzej,

> On 5 Oct 2025, at 21:15, Andrzej Krzemienski via SG15 <sg15_at_[hidden]> wrote:
> I do not think it should be left to implementations. I think the Standard should guarantee that if an assertion predicate is evaluated using the `enforce` mode, the preconditions of functions called in that predicate are also evaluated in `enforce` mode. But I am not sure if this is implementable.

I don't know if it's implementable or not — implementers are encouraged to experiment — but I'm pretty sure such guarantees cannot be obtained with current tooling, so requiring a new language feature to offer those guarantees would make it dead on arrival.

In addition, there are precondition checks that you would never blanket-enforce (e.g., is_sorted() on binary_search()), so any proposal to give you the guarantees you ask for would need to answer the question how to deal with that.

Cheers,
Timur


Received on 2025-10-05 20:32:08