Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Table of Content Zone
maxLevel3
minLevel3
locationtop

Assignment

Includes all expression nodes used for assignment.

++a

Preincrement expression. For example:

Code Block
int i = 1;
++i;            // Preincrement ++a

--a

Pre-decrement expression. For example:

Code Block
int i = 1;
--i;            // Predecrement --a

a%=b

Mod-equals operator expression. For example:

Code Block
int i = 2;
int j = 3;
j %= i;        // Mod-equals a%=b

a&=b

Bitwise-and-equals operator expression. For example:

Code Block
int i = 2;
int j = 3;
j &= i;        // Bitwise-and-equals a&=b

a*=b

Multiply-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+=b

Plus-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-=b

Minus-equals operator expression. For example:

Code Block
int i = 1;
int j = 0;
j -= i;                  // Minus-equals a-=b

a/=b

Divide-equals operator expression. For example:

Code Block
int i = 4;
int j = 2;
j /= i;                  // Divide-equals a/=b

a<<=b

Left-shift-equals operator expression. For example:

Code Block
int i = 2;
int j = 3;
j <<= i;                // Left-shift-equals a<<=b

a=b

Assignment operator expression. For example:

Code Block
int i = 1;
int j = 0;
j = i;                  // Assignment a=b

a>>=b

Right-shift-equals operator expression. For example:

Code Block
int i = 2;
int j = 3;
j >>= i;                // Right-shift-equals a>>=b

a^=b

Bitwise-xor-equals operator expression. For example:

Code Block
int i = 2;
int j = 3;
j ^= i;                  // Bitwise-xor-equals a^=b

a|=b

Bitwise-or-equals operator expression. For example:

Code Block
int i = 2;
int j = 3;
j |= i;                  // Bitwise-or-equals a|=b

Bitwise

Expressions involving non-assignment bitwise operators.

a&b

Bitwise 'and' expression. For example:

Code Block
int z = 73, y = 0;
y = z & 0x0f;          // Bitwise 'and' a&b

a^b

Bitwise XOR expression. For example:

Code Block
int z = 73, y = 0;
y = z | 0x0f;          // Bitwise XOR a^b

a|b

Bitwise 'or' expression. For example:

Code Block
int x = 73, y = 0;
y = x | 4;              // Bitwise 'or' a|b

~a

Bitwise 'not' expression. For example:

Code Block
int a = ~3;            // Bitwise 'not' ~a

Comparison

Expressions that compare values.

a!=b

Not-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==b

Equality 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
}

Logical

Comparison expressions involving logical operators.

!a

Logical 'not' expression. For example:

Code Block
bool func(int x) {
    if (!x) {              // !a
        return false;
    }
    return true
}

a&&b

Logical 'and' expression. For example:

Code Block
bool func(int x, int y) {
    if (x && y) {       // a&&b
        return false;
    }
    return true
}

a||b

Logical 'or' expression. For example:

Code Block
bool func(int x, int y) {
    if (x || y) {             // a||b
        return false;
    }
    return true
}

Miscellaneous

Miscellaneous expressions that don't fit in other categories.

&a

Address of expression. For example:

Code Block
int i = 0;
int *j = &i;               // &a

*a

Dereference expression. For example:

Code Block
int *i = new int();
*i = 5;                    // *a

a->b

Dereference operator expression. For example:

Code Block
class A {
public:
    int field;
};
 
main() {
    A *a = new A;
    a->field = 1; // Dereference a->b
}

Anchor
alignof
alignof
alignof

Alignment of type (alignof in C++11 or _Alignof in C11). For example:

Code Block
size_t a = alignof(int); // alignment of type int

Cast

Expression 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 Association

A 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 Selection

A C11 generic selection expression. For example:

Code Block
int is_int = _Generic(10, int: 1, default: 0); // Generic expression

GNU Statement Expression

A 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 List

Expression 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;
};

Overloaded

An 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 >>
}

Label

Label 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,b

Compound statement list. For example:

Code Block
void func() {
    for (int i = 0; i >=0, i < 10; i++) {  
       // a,b in for condition
    }
}

a->*b

Arrow-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.*b

Dot-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.b

Dot 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::b

Obsolete. Formerly used to represent scope reference expressions. Use ScopePrefix instead.

a?b:c

Ternary 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]

asm

Inlined assembly expression. For example:

Code Block
void func() {
   asm(mov eax, ebp);         // asm
}

delete

Delete 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 (...)
}

new

New operator expression. For example:

int *i = new int[20];   // new

sizeof

Sizeof operator expression. For example:

int *i = malloc(20*sizeof(int));  // sizeof

throw

Throw operator expression. For example:

Code Block
void func() {
   throw;                           // throw
}

typeid

Typeid operator expression used for RTTI. For example:

Code Block
class Shape {};
void f(Shape& r) {
   typeid(r);                       // typeid

noexcept

Noexcept operator. For example:

Code Block
bool func(int x, int y) {
    return noexcept(x + y) || noexcept(func(x, y);
}

Vacuous destructor call

Explicit 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();

Lambda

Lambda 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
}

Numerical

Numerical expressions that are not assignments.

+a

Positive signed expression. For example:

Code Block
int func(int num) {
   return +num;                // +a
}

-a

Negative signed expression. For example:

Code Block
int func(int num) {
   return -num;                // -a
}

a%b

Modulo expression. For example:

Code Block
int j = 2;
int k = 5 % j;                 // Mod a%b

a*b

Multiplication expression. For example:

Code Block
int j = 1;
int k = 3 * j;                 // Multiplication a*b

a+b

Addition expression. For example:

Code Block
int j = 1;
int k = 3 + j;                 // Multiplication a+b

a-b

Subtraction expression. For example:

Code Block
int j = 1;
int k = 3 - j;           // Subtraction a-b

a/b

Division expression. For example:

Code Block
int j = 2;
int k = 5 / j;           // Division a/b

a<<b

Left-shift expression. For example:

Code Block
int i = 1, j = 1, k = 1;
k = i << j;              // Left-shift a<<b

a>>b

Right-shift expression. For example:

Code Block
int i = 1, j = 1, k = 1;
k = i >> j;              // Right-shift a>>b

...