[Development] Disavowing the Lakos Rule for Q_ASSERT

Ville Voutilainen ville.voutilainen at gmail.com
Fri Aug 30 05:17:57 CEST 2024


On Fri, 30 Aug 2024 at 04:59, Thiago Macieira <thiago.macieira at intel.com> wrote:

> Said macro should be tied to the precondition itself, if we can. I haven't
> looked at the syntax: can one macro in one location expand to preconditions-
> or-noexcept-or-both?

Yes. Here's an example of the syntax for you:

void f(int x) noexcept pre(x >= 0);

The contracts go after everything else, pretty much. Be aware, though,
that a trailing return type
goes after a noexcept-spec, and contracts go after a trailing return type.

The full adjusted grammar is in section labeled "Modify [dcl.fct],
paragraph 1", page 71, in
https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2024/p2900r8.pdf

If you look at the next page, you'll see that virt-specifiers go after
a declarator and contracts
go after the virt-specifiers, so you may also have virt-specifiers in
between a noexcept-spec and a contract.
Ain't macroing things fun in C++?


More information about the Development mailing list