[C++][Visual Studio]Visual studio 2010 C++0x new feature: static_assert
#include “stdafx.h”
#define DEFAULT_VALUE 0 #define MAX_VALUE 100
const int VALUE = 10;
struct MyStruct { char data[1024]; };
template < class T, int Size > class Vector { static_assert(Size > 0, “Vector size must be bigger than zero!”);
T m_values[Size]; };
int _tmain(int argc, _TCHAR* argv[]) { static_assert( sizeof(void ) == 4, “64-bit code generation is not supported.”); static_assert( MAX_VALUE > DEFAULT_VALUE, “DEFAULT_VALUE must be smaller than MAX_VALUE” ); static_assert( MAX_VALUE > VALUE, “VALUE must be smaller than MAX_VALUE” ); static_assert( sizeof( MyStruct ) < 10241024, “The structure size exceeds stack size” ); Vector<int, 10> intArray; return 0; }