Created
June 17, 2012 03:13
-
-
Save hpcx82/2943277 to your computer and use it in GitHub Desktop.
A macro to get array size
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#ifndef _LZ_UTILITY_COMMON_H | |
#define _LZ_UTILITY_COMMON_H | |
// Array size | |
template <typename T, size_t N> | |
char ( &_ArraySizeHelper( T (&array)[N] ) ) [N]; | |
#define ARRAY_SIZE(array) ( sizeof( _ArraySizeHelper(array) ) ) | |
#endif |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment