From 564f445125c144266528f21cc76ca38b64f3bd38 Mon Sep 17 00:00:00 2001 From: Abhinav Agarwal Date: Wed, 17 Jun 2026 08:49:01 -0700 Subject: [PATCH] [basic.def.odr] Make a lambda contract predicate odr-usable for captures The odr-usability rule's lambda bullet (bullet 4) required the lambda's block scope to be an intervening scope, but a function contract predicate (e.g. [i] pre(i > 0) {}) lives in the lambda-declarator, in a contract-assertion scope outside the block scope. This made the normative [expr.prim.lambda] example "auto f3 = [i] pre(i > 0) {}; // OK" ill-formed. Allow the second conjunct to be satisfied by a contract-assertion scope introduced by a function contract assertion of the lambda-expression, in addition to its block scope, while preserving the CWG 2380 default-argument case as ill-formed. --- source/basic.tex | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/source/basic.tex b/source/basic.tex index c1f58de60a..a5f0d73cf6 100644 --- a/source/basic.tex +++ b/source/basic.tex @@ -627,7 +627,10 @@ a \grammarterm{lambda-expression} that has a \grammarterm{simple-capture} naming the entity or has a \grammarterm{capture-default}, and -the block scope of the \grammarterm{lambda-expression} +the block scope of the \grammarterm{lambda-expression}, +or a contract-assertion scope\iref{basic.scope.contract} +introduced by a function contract assertion\iref{dcl.contract.func} +of the call operator or operator template of that \grammarterm{lambda-expression}, is also an intervening scope. \end{itemize} \end{itemize}