Overview of the Swap Operator¶
The <-> operator exchanges two mutable values:
Arrays swap element by element, and structures normally receive a generated memberwise swap:
A user-defined type can declare .OPERATOR<-> when it needs different behavior.
Unions and variants swap their active alternatives as well as their payloads.
Polymorphic structs do not receive generated swap; see
Inheritance.
Reference¶
Swap keeps both objects alive; it is not destruction followed by construction. For generation rules, suppression modifiers, and self-swap behavior, see the Swap Operator Reference.