[+][@][!][~][-][*][*][*][&]operand
Example: -10. Here - is operator, 10 is operand.
Operators:
| ! | The logical-negation (logical-NOT) operator produces the value 0 if its operand is true (nonzero) and the value 1 if its operand is false (0). The result has int type. |
| ~ | The bitwise-complement (bitwise-NOT) operator produces the bitwise complement of its operand. The result has the type of the operand. |
| - | The arithmetic-negation operator produces the negative of its operand. The result has the type of the operand. |
| * | The indirection operator accesses a value indirectly, through a pointer. The operand must be a pointer value. The result is the value at the address to which operand points. The type of the result is the type that the operand addresses. |
| & | The address-of operator gives the address of its operand. The operand can be either a variable or a function name. The result is a pointer to (address of) the operand. If operand is non-initialized reference-variable, result is 0. |
| + | The type cast operator. In assignment operations (=, ret, function arguments), if the left expression has pointer type (pointer, lpstr, interface pointer), the right expression must have the same type (or it can be 0). Otherwise, QM may generate error. If you are sure that such assignment is not a mistake, you can use operator + to compile without error. Pointer type checking is less strict with operator = and ret than with function arguments. See the example. |
| @ | QM 2.3.0. Converts string to Unicode UTF-16. The operand must be a string (lpstr or str). The result is Unicode UTF-16 string. Use when calling dll functions that accept UTF-16 strings as input arguments. Argument type usually is @* (word pointer; in C++ would be LPWSTR, OLECHAR* or similar), but also can be BSTR or int (for example with SendMessageW). Example. |
Unary operators must be placed immediately before operand. With operators !, ~ and -, operand can be any expression. With operator *, operand can be any expression that has pointer type.
Unary operators are applied before binary operators, but after operators . (member access) and [] (array element access). If used more than one unary operator with the same operand, they must be in the order specified above, and are applied from right to left.
See also: pointer and reference variables
a = -b if(c > -10) a = Func(-10 ~(d|e)) if(!win("Notepad")) out "Notepad window not found" int* ip = &i j = *ip *ip = 10 POINT p; GetCursorPos(&p) int* p = 1 ;;error int* p = +1 ;;compiles without error int* p = 1+2 ;;error int* p = +(1+2) ;;compiles without error