40 #ifndef INCLUDED_GLS_CPP_LANG_SUPPORT_H
41 #define INCLUDED_GLS_CPP_LANG_SUPPORT_H
70 #if _MSC_VER >= 1700 // >= VS2012
71 #define DISTI_HAS_RVAL_REFS
72 #define DISTI_HAS_METHOD_OVERRIDE
73 #define DISTI_HAS_TYPE_TRAITS
74 #define DISTI_HAS_STATIC_ASSERT
76 #if _MSC_VER >= 1800 // >= VS2013
77 #define DISTI_HAS_SPECIAL_MEM_FUN_DEL
82 #elif defined( __GNUC__ )
84 #if __cpp_rvalue_references >= 200610 || ( (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)) && ( defined(__GXX_EXPERIMENTAL_CXX0X__) || __cplusplus >= 201103L ) )
85 #define DISTI_HAS_RVAL_REFS
87 #if __cpp_static_assert >= 200410 && ( defined(__GXX_EXPERIMENTAL_CXX0X__) || __cplusplus >= 201103L )
88 #define DISTI_HAS_STATIC_ASSERT
90 #if (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 7)) && ( defined(__GXX_EXPERIMENTAL_CXX0X__) || __cplusplus >= 201103L )
91 #define DISTI_HAS_METHOD_OVERRIDE
94 #define DISTI_HAS_TYPE_TRAITS
96 #if (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)) && ( defined(__GXX_EXPERIMENTAL_CXX0X__) || __cplusplus >= 201103L )
97 #define DISTI_HAS_SPECIAL_MEM_FUN_DEL
102 #elif defined( __clang__ )
103 #if __has_feature(cxx_rvalue_references)
104 #define DISTI_HAS_RVAL_REFS
106 #if __has_feature(cxx_override_control)
107 #define DISTI_HAS_METHOD_OVERRIDE
109 #if __has_feature(cxx_defaulted_functions) && __has_feature(cxx_deleted_functions)
110 #define DISTI_HAS_SPECIAL_MEM_FUN_DEL
112 #if __has_feature(cxx_static_assert)
113 #define DISTI_HAS_STATIC_ASSERT
117 #define DISTI_HAS_TYPE_TRAITS
123 #ifdef DISTI_HAS_CPP11 // A single switch to enable everything since compiler is highly compliant
125 #define DISTI_IF_HAS_CPP11( x ) x
126 #define DISTI_IF_HAS_CPP11_ELSE( x, y ) x
128 #define DISTI_HAS_RVAL_REFS
129 #define DISTI_HAS_METHOD_OVERRIDE
130 #define DISTI_HAS_SPECIAL_MEM_FUN_DEL
131 #define DISTI_HAS_TYPE_TRAITS
132 #define DISTI_HAS_STATIC_ASSERT
133 #else // Not fully C++11; some features may be enabled piecemeal
135 #define DISTI_IF_HAS_CPP11( x )
136 #define DISTI_IF_HAS_CPP11_ELSE( x, y ) y
142 #if !defined( DISTI_NO_RVAL_REFS ) && defined( DISTI_HAS_RVAL_REFS )
144 #define DISTI_RVAL_MOVE(x) std::move(x)
145 #define DISTI_IF_HAS_RVAL_REFS_ELSE( x, y ) x
147 #undef DISTI_HAS_RVAL_REFS
148 #define DISTI_RVAL_MOVE(x) (x)
149 #define DISTI_IF_HAS_RVAL_REFS_ELSE( x, y ) y
153 #if !defined( DISTI_NO_METHOD_OVERRIDE ) && defined( DISTI_HAS_METHOD_OVERRIDE )
155 #define DISTI_METHOD_OVERRIDE override
157 #define DISTI_METHOD_FINAL final
159 #undef DISTI_HAS_METHOD_OVERRIDE
160 #define DISTI_METHOD_OVERRIDE
161 #define DISTI_METHOD_FINAL
165 #if !defined( DISTI_NO_SPECIAL_MEM_FUN_DEL ) && defined( DISTI_HAS_SPECIAL_MEM_FUN_DEL )
167 #define DISTI_SPECIAL_MEM_FUN_DELETE = delete
169 #undef DISTI_HAS_SPECIAL_MEM_FUN_DEL
170 #define DISTI_SPECIAL_MEM_FUN_DELETE
174 #if !defined( DISTI_NO_TYPE_TRAITS ) && defined( DISTI_HAS_TYPE_TRAITS )
177 #define DISTI_IF_HAS_TYPE_TRAITS_ELSE( x, y ) x
179 #undef DISTI_HAS_TYPE_TRAITS
180 #define DISTI_IF_HAS_TYPE_TRAITS_ELSE( x, y ) y
186 namespace _cppLangSupportDetail
202 template <
class T,
class U>
207 struct Big {
char dummy[2]; };
208 static Big Test(...);
209 static Small Test(U);
212 enum { value =
sizeof(Small) ==
sizeof((Test(MakeT()))) };
224 #if defined( DISTI_NO_STATIC_ASSERT )
225 #undef DISTI_HAS_STATIC_ASSERT
226 #define DISTI_STATIC_ASSERT( expr, msg )
228 #define DISTI_PREPROC_STRINGIFY_HELPER(s) #s
229 #define DISTI_PREPROC_STRINGIFY(s) DISTI_PREPROC_STRINGIFY_HELPER(s)
231 #if defined( DISTI_HAS_STATIC_ASSERT )
239 #define DISTI_STATIC_ASSERT( expr, msg ) static_assert( expr, DISTI_PREPROC_STRINGIFY(msg) )
243 namespace _cppLangSupportDetail
260 #define DISTI_STATIC_ASSERT(expr, msg) \
262 ::disti::_cppLangSupportDetail::CompileTimeError<((expr) != 0)> ERROR_##msg; \
263 (void) ERROR_##msg; \
276 #ifdef DISTI_HAS_TYPE_TRAITS
277 #define DISTI_STATIC_ASSERT_IS_CONVERTIBLE_TO( T, ConvertsTo ) DISTI_STATIC_ASSERT( (std::is_convertible<T*,ConvertsTo*>::value), class_does_not_inherit_from_##ConvertsTo );
279 #define DISTI_STATIC_ASSERT_IS_CONVERTIBLE_TO( T, ConvertsTo ) DISTI_STATIC_ASSERT( (::disti::_cppLangSupportDetail::is_convertible< T*, ConvertsTo* >::value), class_does_not_inherit_from_##ConvertsTo )
Replacement for std::is_convertible, adapted from Loki 0.1.7.
Definition: gls_cpp_lang_support.h:203
Definition: gls_cpp_lang_support.h:247
Definition: bmpimage.h:46