Effective implementation of algorithms (Master Thesis)
Effective and error-free implementation of algorithms
src/utils/macros/array_size.h File Reference

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 Documentation

#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


Function Documentation

template<typename T , unsigned int N>
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.

template<typename T , unsigned int N>
char(& ArraySizeHelper ( const T(&)  array[N]) )[N]
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines