Skip to content

P1323R2 Contract postconditions and return type deduction #2742

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 11, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion source/declarations.tex
Original file line number Diff line number Diff line change
Expand Up @@ -8316,13 +8316,19 @@
The attribute may be applied to the function type of a function declaration.
A postcondition may introduce an identifier to represent
the glvalue result or the prvalue result object of the function.
When the declared return type of a non-templated function
contains a placeholder type,
the optional \grammarterm{identifier} shall only be present in a definition.
\begin{example}
\begin{codeblock}
int f(char * c)
[[ensures res: res > 0 && c != nullptr]];

int g(double * p)
[[ensures audit res: res != 0 && p != nullptr && *p <= 0.0]];

auto h(int x)
[[ensures res: true]]; // error: cannot name the return value
\end{codeblock}
\end{example}

Expand Down Expand Up @@ -8436,7 +8442,10 @@
\pnum
The predicate of a contract condition has the same semantic restrictions
as if it appeared as the first \grammarterm{expression-statement}
in the body of the function it applies to.
in the body of the function it applies to,
except that the return type of the function is
known in a contract condition appertaining to its definition,
even if the return type contains a placeholder type.

\pnum
A precondition is checked by evaluating its predicate
Expand Down
5 changes: 5 additions & 0 deletions source/templates.tex
Original file line number Diff line number Diff line change
Expand Up @@ -5085,6 +5085,11 @@
\mname{func}\iref{dcl.fct.def.general}, where any enclosing function is a
template, a member of a class template, or a generic lambda,

\item
the \grammarterm{identifier} introduced in
a postcondition\iref{dcl.attr.contract} to represent the result of
a templated function whose declared return type contains a placeholder type,

\item
a
\grammarterm{template-id}
Expand Down