14 #define _STDEX_HAS_FEATURE_BUILTIN(xxx) 0
16 #define _STDEX_HAS_FEATURE_BUILTIN(xxx) __has_feature(xxx)
18#ifndef __has_extension
19 #define _STDEX_HAS_EXTENSION_BUILTIN(xxx) _STDEX_HAS_FEATURE_BUILTIN(xxx)
21 #define _STDEX_HAS_EXTENSION_BUILTIN(xxx) __has_extension(xxx)
27#if ((__cplusplus >= 201103L) || (_MSC_VER >= 1900) || (_STDEX_HAS_FEATURE_BUILTIN(cxx_constexpr) || (_STDEX_HAS_EXTENSION_BUILTIN(cxx_constexpr))))
29 #define _STDEX_NATIVE_CPP11_SUPPORT
30 #define _STDEX_NATIVE_CPP11_TYPES_SUPPORT
31 #define _STDEX_NATIVE_CPP_98_SUPPORT
37 #define _STDEX_NATIVE_CPP_98_SUPPORT
40#if !defined(_STDEX_NATIVE_CPP11_TYPES_SUPPORT)
42 #if ((__cplusplus > 199711L) || defined(__CODEGEARC__) || defined(__GXX_EXPERIMENTAL_CXX0X__) || defined(__cpp_unicode_characters) || _STDEX_HAS_FEATURE_BUILTIN(cxx_unicode_literals))
43 #define _STDEX_NATIVE_CPP11_TYPES_SUPPORT
46 #if (defined(__apple_build_version__) && (__clang_major__ >= 3))
47 #ifndef _STDEX_NATIVE_CPP11_TYPES_SUPPORT
48 #define _STDEX_NATIVE_CPP11_TYPES_SUPPORT
54#if (_STDEX_HAS_FEATURE_BUILTIN(cxx_nullptr) || _STDEX_HAS_EXTENSION_BUILTIN(cxx_nullptr))
55 #define _STDEX_NATIVE_NULLPTR_SUPPORT
58#if ((!defined(_MSC_VER) || _MSC_VER < 1600) && !defined(_STDEX_NATIVE_CPP11_SUPPORT))
61 #if !defined(_STDEX_NATIVE_NULLPTR_SUPPORT)
63 #define _STDEX_IMPLEMENTS_NULLPTR_SUPPORT
65 #define STRINGIZE_HELPER(xxx) #xxx
66 #define STRINGIZE(xxx) STRINGIZE_HELPER(xxx)
67 #define WARNING(desc) message(__FILE__ "(" STRINGIZE(__LINE__) ") : warning: " desc)
69 #pragma WARNING("stdex library - macro 'nullptr' was previously defined by user; ignoring stdex macro definition")
71 #undef STRINGIZE_HELPER
77 #if (_STDEX_HAS_FEATURE_BUILTIN(cxx_static_assert) || _STDEX_HAS_EXTENSION_BUILTIN(cxx_static_assert))
78 #define _STDEX_NATIVE_STATIC_ASSERT_SUPPORT
80 #if !defined(static_assert)
81 #define _STDEX_IMPLEMENTS_STATIC_ASSERT_SUPPORT
83 #define STRINGIZE_HELPER(x) #x
84 #define STRINGIZE(x) STRINGIZE_HELPER(x)
85 #define WARNING(desc) message(__FILE__ "(" STRINGIZE(__LINE__) ") : warning: " desc)
87 #pragma WARNING("stdex library - macro 'static_assert' was previously defined by user; ignoring stdex macro definition")
89 #undef STRINGIZE_HELPER
97#if !defined(_STDEX_NATIVE_NULLPTR_SUPPORT)
98 #define _STDEX_NATIVE_NULLPTR_SUPPORT
100 #define _STDEX_NATIVE_STATIC_ASSERT_SUPPORT
104#if (_MSC_VER >= 1600)
106 #ifndef _STDEX_NATIVE_CPP11_TYPES_SUPPORT
107 #define _STDEX_NATIVE_CPP11_TYPES_SUPPORT
116 #define _STDEX_NATIVE_MICROSOFT_COMPILER_EXTENSIONS_SUPPORT
117 #define _STDEX_CDECL __cdecl
118 #define _STDEX_STDCALL __stdcall
119 #define _STDEX_FASTCALL __fastcall
121 #if (__cplusplus >= 199711L)
122 #define _STDEX_NATIVE_CPP_98_SUPPORT
128#if (__cplusplus >= 199711L)
129 #if (defined(__INTEL_COMPILER) || defined(__clang__))
130 #ifndef _STDEX_NATIVE_CPP_98_SUPPORT
131 #define _STDEX_NATIVE_CPP_98_SUPPORT
137 #if (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)
138 #ifndef _STDEX_NATIVE_CPP_98_SUPPORT
139 #define _STDEX_NATIVE_CPP_98_SUPPORT
142 #if !__x86_64__ && !__ppc64__
143 #define _STDEX_CDECL __attribute__((cdecl))
144 #define _STDEX_STDCALL __attribute__((stdcall))
145 #define _STDEX_FASTCALL __attribute__((fastcall))
150 #define forever for(;;)
152 #define STRINGIZE_HELPER(xxx) #xxx
153 #define STRINGIZE(xxx) STRINGIZE_HELPER(xxx)
154 #define WARNING(desc) message(__FILE__ "(" STRINGIZE(__LINE__) ") : warning: " desc)
156 #pragma WARNING("stdex library - macro 'forever' was previously defined by user; ignoring stdex macro definition")
158 #undef STRINGIZE_HELPER
168 #define stdex_assert(condition, message) \
170 if (! (condition)) { \
171 std::cerr << "Assertion `" #condition "` failed in " << __FILE__ \
172 << " line " << __LINE__ << ": " << message << std::endl; \
177 #define stdex_assert(condition, message) ((void)0)
181#ifdef _STDEX_NATIVE_CPP11_SUPPORT
188 template <
class _Tp, std::
size_t _Count>
189 constexpr std::size_t _my_countof(_Tp
const (&)[_Count])
noexcept
195 #define countof(arr) stdex::detail::_my_countof(arr)
196 #define STATIC_ASSERT(expression, message) static_assert((expression), #message)
198 #ifdef _STDEX_NATIVE_NULLPTR_SUPPORT
201 typedef std::nullptr_t nullptr_t;
210 #if defined(_STDEX_IMPLEMENTS_NULLPTR_SUPPORT) && !defined(_STDEX_NATIVE_NULLPTR_SUPPORT)
215 typedef std::nullptr_t nullptr_t;
224 struct StaticAssertion;
227 struct StaticAssertion<true>
232 struct StaticAssertionTest
238 #define CONCATENATE(arg1, arg2) CONCATENATE1(arg1, arg2)
239 #define CONCATENATE1(arg1, arg2) CONCATENATE2(arg1, arg2)
240 #define CONCATENATE2(arg1, arg2) arg1##arg2
242 #define STATIC_ASSERT(expression, message)\
243 struct CONCATENATE(__static_assertion_at_line_, __LINE__)\
245 stdex::detail::StaticAssertion<bool((expression))> CONCATENATE(CONCATENATE(CONCATENATE(STATIC_ASSERTION_FAILED_AT_LINE_, __LINE__), _WITH__), message);\
247 typedef stdex::detail::StaticAssertionTest<sizeof(CONCATENATE(__static_assertion_at_line_, __LINE__))> CONCATENATE(__static_assertion_test_at_line_, __LINE__)
249#ifdef _STDEX_IMPLEMENTS_STATIC_ASSERT_SUPPORT
253 #define static_assert(expression, message) STATIC_ASSERT(expression, ERROR_MESSAGE_STRING)
257 #ifdef _STDEX_NATIVE_MICROSOFT_COMPILER_EXTENSIONS_SUPPORT
259 #define countof(arr) _countof(arr)
261 #elif defined(_STDEX_NATIVE_CPP_98_SUPPORT)
263 template <
class _Tp, std::
size_t _Count>
264 char(&COUNTOF_REQUIRES_ARRAY_ARGUMENT(_Tp(&)[_Count]))[_Count];
266 #define countof(xxx) sizeof(COUNTOF_REQUIRES_ARRAY_ARGUMENT(xxx))
268 #define countof(arr) sizeof(arr) / sizeof(arr[0])
272#ifdef _STDEX_NATIVE_CPP11_SUPPORT
274#define stdex_noexcept noexcept
278#define stdex_noexcept throw()
284 #define stdex_char16_t stdex::uint_least16_t
287 #define stdex_char32_t stdex::uint_least32_t
291#undef _STDEX_HAS_FEATURE_BUILTIN
292#undef _STDEX_HAS_EXTENSION_BUILTIN