PrevUpHome

Supported operators

Unary operators
prefix:   ~, !, -, +, ++, --, & (reference), * (dereference)
postfix:  ++, --
Binary operators
=, [], +=, -=, *=, /=, %=, &=, |=, ^=, <<=, >>=
+, -, *, /, %, &, |, ^, <<, >>
==, !=, <, >, <=, >=
&&, ||, ->*
Ternary operator
if_else(c, a, b)

The ternary operator deserves special mention. Since C++ does not allow us to overload the conditional expression: c ? a : b, the if_else pseudo function is provided for this purpose. The behavior is identical, albeit in a lazy manner.

Member pointer operator
a->*member_object_pointer
a->*member_function_pointer

The left hand side of the member pointer operator must be an actor returning a pointer type. The right hand side of the member pointer operator may be either a pointer to member object or pointer to member function.

If the right hand side is a member object pointer, the result is an actor which, when evaluated, returns a reference to that member. For example:

struct A
{
    int member;
};

A* a = new A;
...

(arg1->*&A::member)(a); // returns member a->member

If the right hand side is a member function pointer, the result is an actor which, when invoked, calls the specified member function. For example:

struct A
{
    int func(int);
};

A* a = new A;
int i = 0;

(arg1->*&A::func)(arg2)(a, i); // returns a->func(i)

PrevUpHome