Operator precedence |
L-R |
R-L |
L-R |
R-L |
L-R |
:: |
i++ i-- |
() |
[] |
. |
-> |
++i --i |
+i -i |
! ~ |
(type) |
*
|
& |
new |
delete |
.* ->* |
* / % |
+ - |
<< >> |
< <= |
> >= |
== != |
& |
^ |
| |
&& |
|| |
c ? t : f |
= |
+= -= |
*= /= %= |
<<= >>= |
&= ^= |= |
, |
|
Suffixes |
TType operator "" _suf(const char * Literal); |
123_suf |
"123" |
TType operator "" _suf(unsigned long long); |
123_suf |
unsigned long long 123 |
TType operator "" _suf(long double); |
3.14_suf |
long double 3.14 |
TType operator "" _suf(const char* Val, size_t Len); |
"123"_suf |
"123", 3 |
template<char...> TType operator "" _suf(); |
123_suf |
operator "" _suf<'1','2','3'>() |
|
Assembly Jcc |
CMP EAX,EDX Ja Dest //Jumps if EAX>EDX |
Unsigned |
C Z |
Bin logic |
Above |
0 & 0 |
C & Z |
Below |
1 | X |
C |
Above or Equal |
0 & X |
!C |
Below or Equal |
1 | 1 |
C | Z |
Signed |
Greater |
Z & (S & O | S & O ) |
Less |
S & O | S & O |
Greater or Equal |
S & O | S & O |
Less or Equal |
Z | (S & O | S & O) |
Loops |
for(Initialization;Condition;Increment) Statement; |
do Statement while(Condition); |
while(Condition) Statement; |
break
continue | exits loop ends current iteration |
Enums |
enum TEnumType {Value1=const, ...}; |
enum class TEnumType {...}; |
enum class TEnumType : BaseType {...}; |
Const and pointers |
int * | pointer to int |
const int * | pointer to const int |
int * const | const Pointer to int |
const int * const | const pointer to const int |
|
Templates |
template<typename T>friend class TFriendClass; // Every TFriendClass<T> |
template<typename T, bool> class Selector {typedef TClassType01<T> ClassType;};
template<typename T> class Selector<T, true> {typedef TClassType02<T> ClassType;}; |
template<typename T>T Max() {return ~0;};
template<> char Max<char>() {return 0xFF;};
|
template<typename T1, typename T2>class TDemo {/* Default for any 2 types */};
template<> class TDemo<char, char> {/* Alternative for char, char */};
template<typename T;> class TDemo<char, T> {/* Alternative for char, T */};
|
|
Typedefs and function pointers |
typedef ExistingType Alias; |
typedef int (*FuncType)(int Param); |
using FuncType = int (*)(int); |
typedef int (TClass::*MemberFuncType)(int Param); |
template <typename T1, typename T2, const int C>class TType { /* Implementation */};
template <typename T>using TypedefName = TType<int, T, 5>; |
|
Lambda expressions |
[capture](parameters) -> return_type { function_body } |
[](int x, int y) -> int { return x + y; } |
auto MyLambdaFunc = [](int x) { /*...*/ }; |
Capture |
[] | No variables captured. |
[x, &y] | x by value, y is by reference |
[&] | Any variable by reference if used |
[=] | Any variable by value if used |
[&, x] | x by value. Others by reference |
[=, &z] | z by reference. Others by value |
|