AssignmentIncludes all expression nodes used for assignment. ++aPreincrement expression. For example: Code Block |
---|
int i = 1;
++i; // Preincrement ++a |
--aPre-decrement expression. For example: Code Block |
---|
int i = 1;
--i; // Predecrement --a |
a%=bMod-equals operator expression. For example: Code Block |
---|
int i = 2;
int j = 3;
j %= i; // Mod-equals a%=b |
a&=bBitwise-and-equals operator expression. For example: Code Block |
---|
int i = 2;
int j = 3;
j &= i; // Bitwise-and-equals a&=b |
a*=bMultiply-equals operator expression. For example: Code Block |
---|
int i = 2;
int j = 3;
j *= i; // Multiply-equals a*=b |
a++Post increment expression. For example: Code Block |
---|
int i = 1;
i++; // Postincrement a++
|
a+=bPlus-equals operator expression. For example: Code Block |
---|
int i = 1;
int j = 0;
j += i; // Plus-equals a+=b |
a--Post decrement expression. For example: Code Block |
---|
int i = 1;
i--; // Postdecrement a-- |
a-=bMinus-equals operator expression. For example: Code Block |
---|
int i = 1;
int j = 0;
j -= i; // Minus-equals a-=b |
a/=bDivide-equals operator expression. For example: Code Block |
---|
int i = 4;
int j = 2;
j /= i; // Divide-equals a/=b |
a<<=bLeft-shift-equals operator expression. For example: Code Block |
---|
int i = 2;
int j = 3;
j <<= i; // Left-shift-equals a<<=b |
a=bAssignment operator expression. For example: Code Block |
---|
int i = 1;
int j = 0;
j = i; // Assignment a=b |
a>>=bRight-shift-equals operator expression. For example: Code Block |
---|
int i = 2;
int j = 3;
j >>= i; // Right-shift-equals a>>=b |
a^=bBitwise-xor-equals operator expression. For example: Code Block |
---|
int i = 2;
int j = 3;
j ^= i; // Bitwise-xor-equals a^=b |
a|=bBitwise-or-equals operator expression. For example: Code Block |
---|
int i = 2;
int j = 3;
j |= i; // Bitwise-or-equals a|=b |
BitwiseExpressions involving non-assignment bitwise operators. a&bBitwise 'and' expression. For example: Code Block |
---|
int z = 73, y = 0;
y = z & 0x0f; // Bitwise 'and' a&b |
a^bBitwise XOR expression. For example: Code Block |
---|
int z = 73, y = 0;
y = z | 0x0f; // Bitwise XOR a^b |
a|bBitwise 'or' expression. For example: Code Block |
---|
int x = 73, y = 0;
y = x | 4; // Bitwise 'or' a|b |
~aBitwise 'not' expression. For example: Code Block |
---|
int a = ~3; // Bitwise 'not' ~a |
ComparisonExpressions that compare values. a!=bNot-equal operator expression. For example: Code Block |
---|
bool func(int x) {
if (x!=3) { // a!=b
return false;
}
return true
} |
a<=b'Less than or equals' expression. For example: Code Block |
---|
bool func(int x) {
if (x <= 3) { // a<=b
return false;
}
return true
} |
a<b'Less than' expression. For example: Code Block |
---|
bool func(int x) {
if (x<3) { // a<b
return false;
}
return true
} |
a==bEquality operator expression. For example: Code Block |
---|
bool func(int x) {
if (x==3) { // a==b
return false;
}
return true
} |
a>=b'Greater than or equals' expression. For example: Code Block |
---|
bool func(int x) {
if (x >= 3) { // a>=b
return false;
}
return true
} |
a>b'Greater than' expression. For example: Code Block |
---|
bool func(int x) {
if (x > 3) { // a>b
return false;
}
return true
} |
LogicalComparison expressions involving logical operators. !aLogical 'not' expression. For example: Code Block |
---|
bool func(int x) {
if (!x) { // !a
return false;
}
return true
} |
a&&bLogical 'and' expression. For example: Code Block |
---|
bool func(int x, int y) {
if (x && y) { // a&&b
return false;
}
return true
} |
a||bLogical 'or' expression. For example: Code Block |
---|
bool func(int x, int y) {
if (x || y) { // a||b
return false;
}
return true
} |
MiscellaneousMiscellaneous expressions that don't fit in other categories. &aAddress of expression. For example: Code Block |
---|
int i = 0;
int *j = &i; // &a |
*aDereference expression. For example: Code Block |
---|
int *i = new int();
*i = 5; // *a |
a->bDereference operator expression. For example: Code Block |
---|
class A {
public:
int field;
};
main() {
A *a = new A;
a->field = 1; // Dereference a->b
} | alignofAlignment of type (alignof in C++11 or _Alignof in C11). For example: Code Block |
---|
size_t a = alignof(int); // alignment of type int |
CastExpression that casts from one type to another. For example: Code Block |
---|
void func() {
char c = 'c';
int i = (int)c; // normal (C-style) cast
} |
Anchor |
---|
| generic_association |
---|
| generic_association |
---|
| Generic AssociationA generic association in a generic selection. For example: Code Block |
---|
_Generic((X)
, int: f_int // Generic association
, float: f_float // Generic association
, default: f_other // Generic association
) |
Anchor |
---|
| generic_selection |
---|
| generic_selection |
---|
| Generic SelectionA C11 generic selection expression. For example: Code Block |
---|
int is_int = _Generic(10, int: 1, default: 0); // Generic expression |
GNU Statement ExpressionA compound statement enclosed in parentheses that may appear as an expression in GNU C. For example: Code Block |
---|
int foo();
void bar(int p){
p=({/* GNU Statement Expression start */
int y = foo ();
int z;
if(y>0)z = y;
else z = -y;
z;
});
} |
Initializer ListExpression containing initializations, used in member functions. For example: Code Block |
---|
class Foo {
public:
Foo() _x(0), _y(0) {} // Initializer list
private:
int _x;
int _y;
}; |
OverloadedAn expression using an overloaded operator. For example: Code Block |
---|
#include <iostream.h>
void func()
{
cout << "Hello, how old are you?" // Overloaded <<
<< endl; // Overloaded <<
int age;
cin >> age; // Overloaded >>
} |
LabelLabel in goto statement. For example: Code Block |
---|
void func()
{
int i;
goto label1; //label with name 'label1'
| := 0;
label1:
|:=1;
} |
a(b)Function call expression. For example: Code Block |
---|
void foo(int i) {}
void bar(int x) {
foo(x); // Function call a(b).
// Left Hand Side is Function foo,
// Right Hand Side is Parameter x
} |
a,bCompound statement list. For example: Code Block |
---|
void func() {
for (int i = 0; i >=0, i < 10; i++) {
// a,b in for condition
}
} |
a->*bArrow-star expression used in pointers to member functions. For example: Code Block |
---|
class Foo {
public:
void func();
};
typedef void(Foo::*mpf)();
void bar(Foo *f) {
mpf ampf = &Foo::func;
(f->*ampf)(); // a->*b
} |
a.*bDot-star expression used in pointers to member functions. For example: Code Block |
---|
class Foo {
public:
void func();
};
typedef void(Foo::*mpf)();
void bar(Foo f) {
mpf ampf = &Foo::func;
(f.*ampf)(); // a.*b
} |
a.bDot operator expression. For example: Code Block |
---|
class Foo {
public:
void func();
int zzz;
};
int bar() {
Foo f;
f.func(); // a.b
return f.zzz; // a.b
} |
a::bObsolete. Formerly used to represent scope reference expressions. Use ScopePrefix instead. a?b:cTernary operator expression. For example: Code Block |
---|
bool func(int x) {
return x ? true : false; // Ternary operator a?b:c
} |
a[b]Array reference. For example: Code Block |
---|
char array[] = "John Doe";
char c = array[0]; // array reference a[b] |
asmInlined assembly expression. For example: Code Block |
---|
void func() {
asm(mov eax, ebp); // asm
} |
deleteDelete operator expression. For example: Code Block |
---|
int *i = new int();
delete(i); // delete |
ellipses (...)Ellipses expression used for catch parameters. For example: Code Block |
---|
void func() {
try {
} catch(...) {} // catch parameter is (...)
} |
newNew operator expression. For example: int *i = new int[20]; // new
sizeofSizeof operator expression. For example: int *i = malloc(20*sizeof(int)); // sizeof
throwThrow operator expression. For example: Code Block |
---|
void func() {
throw; // throw
} |
typeidTypeid operator expression used for RTTI. For example: Code Block |
---|
class Shape {};
void f(Shape& r) {
typeid(r); // typeid |
noexceptNoexcept operator. For example: Code Block |
---|
bool func(int x, int y) {
return noexcept(x + y) || noexcept(func(x, y);
} |
Vacuous destructor callExplicit destructor call for simple types or classes that do not have a type. For simple types, this represents a pseudo-destructor call. For example: Code Block |
---|
struct S {} s;
s.S::~S();
typedef int INT;
int i;
i.INT::~INT(); |
LambdaLambda expression. For example: Code Block |
---|
#include <algorithm>
#include <cmath>
void mySort(float* x, unsigned N)
{
std::sort(x, x + N, [](float a, float b)
{ return a < b; }); // Lambda expression
} |
NumericalNumerical expressions that are not assignments. +aPositive signed expression. For example: Code Block |
---|
int func(int num) {
return +num; // +a
} |
-aNegative signed expression. For example: Code Block |
---|
int func(int num) {
return -num; // -a
} |
a%bModulo expression. For example: Code Block |
---|
int j = 2;
int k = 5 % j; // Mod a%b |
a*bMultiplication expression. For example: Code Block |
---|
int j = 1;
int k = 3 * j; // Multiplication a*b |
a+bAddition expression. For example: Code Block |
---|
int j = 1;
int k = 3 + j; // Multiplication a+b |
a-bSubtraction expression. For example: Code Block |
---|
int j = 1;
int k = 3 - j; // Subtraction a-b |
a/bDivision expression. For example: Code Block |
---|
int j = 2;
int k = 5 / j; // Division a/b |
a<<bLeft-shift expression. For example: Code Block |
---|
int i = 1, j = 1, k = 1;
k = i << j; // Left-shift a<<b |
a>>bRight-shift expression. For example: Code Block |
---|
int i = 1, j = 1, k = 1;
k = i >> j; // Right-shift a>>b |
|