00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00041 #ifndef COMMON_H
00042 #define COMMON_H
00043 #include <cassert>
00044
00045 #define ALWAYS_INLINE __attribute__((__always_inline__))
00046
00047
00048
00049
00053 template<bool>
00054 struct CompileTimeChecker {
00055 CompileTimeChecker(...){}
00056 };
00060 template<>
00061 struct CompileTimeChecker<false> {
00062 };
00063 #define STATIC_ASSERT_ALWAYS(expr, msg) \
00064 { \
00065 class ERROR_##msg {}; \
00066 (CompileTimeChecker<(expr) != 0>(ERROR_##msg())); \
00067 }
00068
00069 #ifdef DEBUG_ON
00070 #define STATIC_ASSERT_DEBUG(expr, msg) STATIC_ASSERT_ALWAYS(expr, msg)
00071 #else
00072 #define STATIC_ASSERT_DEBUG(expr, msg)
00073 #endif
00074
00075
00076
00077
00078
00079
00080
00081
00082
00089 struct Ordering_row_wise {
00090 inline static int get( int const row, int const col,
00091 int const rows, int const cols ) {
00092 return row * cols + col;
00093 }
00094 template<int T_row, int T_col, int T_rows, int T_cols>
00095 struct Get {
00096 static int const index = T_row * T_cols + T_col;
00097 };
00098
00099 };
00100
00104 struct Ordering_col_wise {
00105 inline static int get( int const row, int const col,
00106 int const rows, int const cols ) {
00107 return row + col * rows;
00108 }
00109 template<int T_row, int T_col, int T_rows, int T_cols>
00110 struct Get {
00111 static int const index = T_row + T_col * T_rows;
00112 };
00113 };
00114
00115
00116 #endif