Effective implementation of algorithms (Master Thesis)
Effective and error-free implementation of algorithms
|
Go to the source code of this file.
Defines | |
#define | ARRAY_SIZE(array) (sizeof(ArraySizeHelper(array))) |
Functions | |
template<typename T , unsigned int N> | |
char(& | ArraySizeHelper (T(&array)[N]))[N] |
template<typename T , unsigned int N> | |
char(& | ArraySizeHelper (const T(&array)[N]))[N] |
#define ARRAY_SIZE | ( | array | ) | (sizeof(ArraySizeHelper(array))) |
Macro which can determine size of the array.
Basic usage: int a[5]; cout >> ARRAY_SIZE(a); // 5
int funct(int b*) { cout >> ARRAY_SIZE(b); // compilation error
char(& ArraySizeHelper | ( | T(&) | array[N] | ) | )[N] |
This file contains macro which can determine size of an array
Macro is taken from chrome's basictypes.h. ARRAY_SIZE relies on template matching failure if the argument is not an array.
char(& ArraySizeHelper | ( | const T(&) | array[N] | ) | )[N] |