Сообщение Re[3]: Внезапно, ||= и &&= от 09.08.2025 9:43
Изменено 09.08.2025 9:49 rg45
M>Кстати, а почему ты считаешь, что результат должен быть строго типа bool? Для || и && такого требования нет
Как это нет? И какой, по-твоему, тип результата, например у выражения 42 && 43? int, что ли?
Результатом всех булевских операций является либо true, либо false и третьего не дано. И true, и false оба имеют тип bool.
7.6.14 Logical AND operator
1 The && operator groups left-to-right. The operands are both contextually converted to bool ([conv]). The result is true if both operands are true and false otherwise. Unlike &, && guarantees left-to-right evaluation: the second operand is not evaluated if the first operand is false.
2 The result is a bool. If the second expression is evaluated, the first expression is sequenced before the second expression ([intro.execution]).
7.6.15 Logical OR operator
1 The || operator groups left-to-right. The operands are both contextually converted to bool ([conv]). The result is true if either of its operands is true, and false otherwise. Unlike |, || guarantees left-to-right evaluation; moreover, the second operand is not evaluated if the first operand evaluates to true.
2 The result is a bool. If the second expression is evaluated, the first expression is sequenced before the second expression ([intro.execution]).
M>Кстати, а почему ты считаешь, что результат должен быть строго типа bool? Для || и && такого требования нет
Как это нет? И какой, по-твоему, тип результата, например, у выражения 42 && 43? int, что ли?
Результатом всех булевских операций является либо true, либо false и третьего не дано. И true, и false оба имеют тип bool.
7.6.14 Logical AND operator
1 The && operator groups left-to-right. The operands are both contextually converted to bool ([conv]). The result is true if both operands are true and false otherwise. Unlike &, && guarantees left-to-right evaluation: the second operand is not evaluated if the first operand is false.
2 The result is a bool. If the second expression is evaluated, the first expression is sequenced before the second expression ([intro.execution]).
7.6.15 Logical OR operator
1 The || operator groups left-to-right. The operands are both contextually converted to bool ([conv]). The result is true if either of its operands is true, and false otherwise. Unlike |, || guarantees left-to-right evaluation; moreover, the second operand is not evaluated if the first operand evaluates to true.
2 The result is a bool. If the second expression is evaluated, the first expression is sequenced before the second expression ([intro.execution]).