Ion
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
static_assert.h
Go to the documentation of this file.
1 
18 #ifndef ION_PORT_STATIC_ASSERT_H_
19 #define ION_PORT_STATIC_ASSERT_H_
20 
24 
26 
31 #if (LANG_CXX11 || _MSC_VER >= 1600) && !defined(ION_PLATFORM_NACL)
32 #define ION_PORT_STATIC_ASSERT(expr, message) static_assert(expr, message)
33 
35 
37 #else
38 
40 #define ION__STATIC_ASSERT_CAT0(a, b) a ## b
41 #define ION__STATIC_ASSERT_CAT1(a, b) ION__STATIC_ASSERT_CAT0(a, b)
42 
47 
48 #if __GNUC__
49 # define ION_ATTRIBUTE_UNUSED __attribute__((unused))
50 #else
51 # define ION_ATTRIBUTE_UNUSED
52 #endif
53 
54 #define ION_PORT_STATIC_ASSERT(expr, message) \
55  typedef int ION__STATIC_ASSERT_CAT1(static_assert_failed_at_line, __LINE__)[ \
56  static_cast<bool>(expr) ? 1 : -1] ION_ATTRIBUTE_UNUSED
57 
59 
60 #endif
61 
62 #endif // ION_PORT_STATIC_ASSERT_H_