CKTIS / C++
or_eq — bitwise OR assignment
`or_eq` is an alternative spelling of the C++ `|=` operator. It combines the operands' bits using OR and stores the result in the left operand. It is a reserved language token, not a macro, and requires no header.
Version: C++23; repository compiler flag, production runtime not attested
Syntax
lhs or_eq rhs;or_eq is an alternative spelling of |= with the same operator meaning. The statement lhs or_eq rhs; performs bitwise OR assignment. The token is reserved: it cannot be used as a variable or function name. No header is needed for the operator itself.
For the built-in operation on integers, each result bit is 1 if at least one corresponding operand bit is 1. The result is assigned to lhs. Integral promotions and the usual arithmetic conversions apply, and the result is converted to the left operand's type when stored. The left operand must be a modifiable lvalue; it cannot, for example, be a const variable.
For the built-in operator, lhs or_eq rhs corresponds to lhs = lhs | rhs, except that the expression designating the left operand is evaluated only once. Do not confuse or_eq with or: or means logical ||, whereas or_eq performs a bitwise operation and does not short-circuit. For class types, the same operator-overloading rules apply as for |=.
In the example, 0b0101u and 0b0011u produce 0b0111u, or decimal 7. The operation sets the bits selected by the mask while preserving previously set bits. This entry targets C++23; the supplied sources are a moving working draft, not a frozen C++23 publication.
Examples
#include <iostream>
int main() {
unsigned flags = 0b0101u;
flags or_eq 0b0011u;
std::cout << flags << '\n';
}
Result
7
The displayed code and declared result were verified in an isolated environment using the method recorded in the verification evidence for this exact version.