Operators
Operators combine, compare and update values with predictable type-directed semantics.
Arithmetic and comparison
+ - * / %== != < <= > >=int total = a + b * 2;
bool ordered = a <= b;
Built-in numeric operations use matching operand types. Built-in comparison expressions produce bool.
Two values of the same struct type support == and != when all fields have equality semantics. Comparison is recursive and field-aware, not a raw byte comparison. See struct value equality.
Boolean and bitwise
&& || !& | ^ ~ << >>&& and || evaluate the right-hand expression only when its value is required.
bool canRun = ready && !failed;
uint masked = value & 0xFF;
Assignment and updates
Simple and compound assignment update an addressable value. Prefix and postfix forms increment or decrement numeric values.
value = 10;
value += 5;
value <<= 1;
i++;
--count;
+=-=*=/=%=&=|=^=<<=>>=Operator overloading
Structs can define selected unary/binary operators. See Operator overloading for the exhaustive token lists, declaration rules, overload resolution, derived compound assignment and ownership behavior.
User-defined conversions
Implicit and explicit conversion operators are described in Operator overloading: conversions, including supported contexts, ranking, conflicting pairs and pointer/reference restrictions.
Swap
<-> exchanges two writable values of the same type. The exchange relocates each value directly and does not create an intermediate language-level copy, so move-only ownership values are supported.
int first = 10;
int second = 20;
first <-> second;
unique<Resource> left = new Resource();
unique<Resource> right = new Resource();
left <-> right;
Both operands must be writable storage locations. Their normal move, pin, borrow and lifetime rules still apply.
Atomic compare-exchange
value : expected --> desired is a single boolean expression for conditional atomic replacement. Matching uses built-in equality semantics, including recursive struct, pointer-address and floating-point rules. User-defined operators do not customize atomic comparison. See Atomic values for its evaluation semantics.