… | |
… | |
55 | #endif |
55 | #endif |
56 | |
56 | |
57 | // use C0X decltype for auto declarations until ISO C++ sanctifies them (if ever) |
57 | // use C0X decltype for auto declarations until ISO C++ sanctifies them (if ever) |
58 | #define auto(var,expr) decltype(expr) var = (expr) |
58 | #define auto(var,expr) decltype(expr) var = (expr) |
59 | |
59 | |
|
|
60 | // could use the sizeof (arr) /( sizeof (arr [0]) here, but C++ is |
|
|
61 | // much more obfuscated... :) |
|
|
62 | |
|
|
63 | template<typename T, int N> |
|
|
64 | inline int array_length (const T (&arr)[N]) |
|
|
65 | { |
|
|
66 | return N; |
|
|
67 | } |
|
|
68 | |
60 | // very ugly macro that basically declares and initialises a variable |
69 | // very ugly macro that basically declares and initialises a variable |
61 | // that is in scope for the next statement only |
70 | // that is in scope for the next statement only |
62 | // works only for stuff that can be assigned 0 and converts to false |
71 | // works only for stuff that can be assigned 0 and converts to false |
63 | // (note: works great for pointers) |
72 | // (note: works great for pointers) |
64 | // most ugly macro I ever wrote |
73 | // most ugly macro I ever wrote |