Skip to content

[expr.log.and],[expr.log.or] improve wording symmetry and quality #6574

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
42 changes: 22 additions & 20 deletions source/expressions.tex
Original file line number Diff line number Diff line change
Expand Up @@ -6810,20 +6810,21 @@
\end{bnf}

\pnum
The \tcode{\&\&} operator groups left-to-right. The operands are both
contextually converted to \keyword{bool}\iref{conv}.
The
result is \keyword{true} if both operands are \keyword{true} and
\keyword{false} otherwise. Unlike \tcode{\&}, \tcode{\&\&} guarantees
left-to-right evaluation: the second operand is not evaluated if the
first operand is \keyword{false}.
The \tcode{\&\&} operator groups left-to-right.
The operands are both contextually converted to \keyword{bool}\iref{conv}.
The result is a prvalue of type \keyword{bool}.
The result is
\keyword{true} if both operands are \keyword{true} and
\keyword{false} otherwise.

\pnum
The result is a \tcode{bool}.
\indextext{operator!side effects and logical AND}%
If the second expression is evaluated,
the first expression is sequenced before
the second expression\iref{intro.execution}.
The right operand is not evaluated if the left operand evaluates to \keyword{false}.
The left operand is sequenced before\iref{intro.execution} the right operand.
\begin{note}
The former behavior is sometimes called "short-circuiting".
The \tcode{\&} operator guarantees neither short-circuiting nor left-to-right evaluation.
\end{note}

\rSec2[expr.log.or]{Logical OR operator}%
\indextext{expression!logical OR}%
Expand All @@ -6837,20 +6838,21 @@
\end{bnf}

\pnum
The \tcode{||} operator groups left-to-right. The operands are both
contextually converted to \keyword{bool}\iref{conv}.
The \tcode{||} operator groups left-to-right.
The operands are both contextually converted to \keyword{bool}\iref{conv}.
The result is a prvalue of type \keyword{bool}.
The result is
\keyword{true} if either of its operands is \keyword{true}, and
\keyword{false} otherwise. Unlike \tcode{|}, \tcode{||} guarantees
left-to-right evaluation; moreover, the second operand is not evaluated
if the first operand evaluates to \keyword{true}.
\keyword{false} otherwise.

\pnum
The result is a \keyword{bool}.
\indextext{operator!side effects and logical OR}%
If the second expression is evaluated,
the first expression is sequenced before
the second expression\iref{intro.execution}.
The right operand is not evaluated if the left operand evaluates to \keyword{true}.
The left operand is sequenced before\iref{intro.execution} the right operand.
\begin{note}
The former behavior is sometimes called "short-circuiting".
The \tcode{|} operator guarantees neither short-circuiting nor left-to-right evaluation.
\end{note}

\rSec2[expr.cond]{Conditional operator}%
\indextext{expression!conditional operator}%
Expand Down