[ < ]  [ > ]  [ << ]  [ Up ]  [ >> ]  [Top]  [Contents]  [Index]  [ ? ] 
12.4.1.1 C and C++ Operators
Operators must be defined on values of specific types. For instance,
+
is defined on numbers, but not on structures. Operators are
often defined on groups of types.
For the purposes of C and C++, the following definitions hold:

Integral types include
int
with any of its storageclass specifiers;char
;enum
; and, for C++,bool
. 
Floatingpoint types include
float
,double
, andlong double
(if supported by the target platform). 
Pointer types include all types defined as
(type *)
.  Scalar types include all of the above.
The following operators are supported. They are listed here in order of increasing precedence:

,
The comma or sequencing operator. Expressions in a commaseparated list are evaluated from left to right, with the result of the entire expression being the last expression evaluated.

=
Assignment. The value of an assignment expression is the value assigned. Defined on scalar types.

op=
Used in an expression of the form
a op= b
, and translated toa = a op b
.op=
and=
have the same precedence. op is any one of the operators
,^
,&
,<<
,>>
,+
,
,*
,/
,%
.
?:
The ternary operator.
a ? b : c
can be thought of as: if a then b else c. a should be of an integral type.

Logical OR. Defined on integral types.

&&
Logical AND. Defined on integral types.


Bitwise OR. Defined on integral types.

^
Bitwise exclusiveOR. Defined on integral types.

&
Bitwise AND. Defined on integral types.

==, !=
Equality and inequality. Defined on scalar types. The value of these expressions is 0 for false and nonzero for true.

<, >, <=, >=
Less than, greater than, less than or equal, greater than or equal. Defined on scalar types. The value of these expressions is 0 for false and nonzero for true.

<<, >>
left shift, and right shift. Defined on integral types.

@
The No value for GDBN “artificial array” operator (see section Expressions).

+, 
Addition and subtraction. Defined on integral types, floatingpoint types and pointer types.

*, /, %
Multiplication, division, and modulus. Multiplication and division are defined on integral and floatingpoint types. Modulus is defined on integral types.

++, 
Increment and decrement. When appearing before a variable, the operation is performed before the variable is used in an expression; when appearing after it, the variable's value is used before the operation takes place.

*
Pointer dereferencing. Defined on pointer types. Same precedence as
++
.
&
Address operator. Defined on variables. Same precedence as
++
.For debugging C++, No value for GDBN implements a use of ‘&’ beyond what is allowed in the C++ language itself: you can use ‘&(&ref)’ (or, if you prefer, simply ‘&&ref’) to examine the address where a C++ reference variable (declared with ‘&ref’) is stored.


Negative. Defined on integral and floatingpoint types. Same precedence as
++
.
!
Logical negation. Defined on integral types. Same precedence as
++
.
~
Bitwise complement operator. Defined on integral types. Same precedence as
++
.
., >
Structure member, and pointertostructure member. For convenience, No value for GDBN regards the two as equivalent, choosing whether to dereference a pointer based on the stored type information. Defined on
struct
andunion
data.
.*, >*
Dereferences of pointers to members.

[]
Array indexing.
a[i]
is defined as*(a+i)
. Same precedence as>
.
()
Function parameter list. Same precedence as
>
.
::
C++ scope resolution operator. Defined on
struct
,union
, andclass
types.
::
Doubled colons also represent the No value for GDBN scope operator (see section Expressions). Same precedence as
::
, above.
If an operator is redefined in the user code, No value for GDBN usually attempts to invoke the redefined version instead of using the operator's predefined meaning.
[ < ]  [ > ]  [ << ]  [ Up ]  [ >> ]  [Top]  [Contents]  [Index]  [ ? ] 