40 #ifndef INCLUDED_GLS_CPP_LANG_SUPPORT_H
41 #define INCLUDED_GLS_CPP_LANG_SUPPORT_H
73 #if defined( _MSC_VER )
74 # if _MSC_VER >= 1700 // >= VS2012
75 # define DISTI_HAS_RVAL_REFS
76 # define DISTI_HAS_METHOD_OVERRIDE
77 # define DISTI_HAS_TYPE_TRAITS
78 # define DISTI_HAS_STATIC_ASSERT
80 # if _MSC_VER >= 1800 // >= VS2013
81 # define DISTI_HAS_SPECIAL_MEM_FUN_DEL
82 # define DISTI_HAS_CPP11
84 # if _MSC_VER >= 1900 // >= VS2015
85 # define DISTI_HAS_USER_DEFINED_LITERALS
87 # if _MSC_VER >= 1911 && __cplusplus >= 201402L // >= VS2017 15.3
88 # define DISTI_HAS_NOEXCEPT
89 # define DISTI_HAS_DEPRECATED_ATTRIBUTE
90 # define DISTI_HAS_CPP14
96 #elif defined( __GNUC__ ) && !defined( __clang__ )
98 # if __cpp_rvalue_references >= 200610 || ( ( __GNUC__ > 4 || ( __GNUC__ == 4 && __GNUC_MINOR__ >= 3 ) ) && ( defined( __GXX_EXPERIMENTAL_CXX0X__ ) || __cplusplus >= 201103L ) )
99 # define DISTI_HAS_RVAL_REFS
101 # if __cpp_static_assert >= 200410 && ( defined( __GXX_EXPERIMENTAL_CXX0X__ ) || __cplusplus >= 201103L )
102 # define DISTI_HAS_STATIC_ASSERT
104 # if( __GNUC__ > 4 || ( __GNUC__ == 4 && __GNUC_MINOR__ >= 9 ) ) && ( defined( __GXX_EXPERIMENTAL_CXX0X__ ) || __cplusplus >= 201103L )
105 # define DISTI_HAS_USER_DEFINED_LITERALS
107 # if( __GNUC__ > 4 || ( __GNUC__ == 4 && __GNUC_MINOR__ >= 7 ) ) && ( defined( __GXX_EXPERIMENTAL_CXX0X__ ) || __cplusplus >= 201103L )
108 # define DISTI_HAS_METHOD_OVERRIDE
109 # define DISTI_HAS_NOEXCEPT
110 # define DISTI_HAS_TYPE_TRAITS // This actually depends on which standard library is in use, but it's a safe bet.
111 # define DISTI_HAS_CPP11
113 # if( __GNUC__ > 4 || ( __GNUC__ == 4 && __GNUC_MINOR__ >= 4 ) ) && ( defined( __GXX_EXPERIMENTAL_CXX0X__ ) || __cplusplus >= 201103L )
114 # define DISTI_HAS_SPECIAL_MEM_FUN_DEL
116 # if( __GNUC__ > 4 || ( __GNUC__ == 4 && __GNUC_MINOR__ >= 9 ) ) && __cplusplus >= 201402L
117 # define DISTI_HAS_DEPRECATED_ATTRIBUTE
118 # define DISTI_HAS_CPP14
124 #elif defined( __clang__ )
125 # if __has_feature( cxx_rvalue_references )
126 # define DISTI_HAS_RVAL_REFS
127 # define DISTI_HAS_CPP11 // Guess that if we have rvalue refs, we've got pretty solid C++11 support
129 # if __has_feature( cxx_override_control )
130 # define DISTI_HAS_METHOD_OVERRIDE
132 # if __has_feature( cxx_noexcept )
133 # define DISTI_HAS_NOEXCEPT
135 # if __has_feature( cxx_defaulted_functions ) && __has_feature( cxx_deleted_functions )
136 # define DISTI_HAS_SPECIAL_MEM_FUN_DEL
138 # if __has_feature( cxx_static_assert )
139 # define DISTI_HAS_STATIC_ASSERT
141 # if __has_feature( cxx_user_literals )
142 # define DISTI_HAS_USER_DEFINED_LITERALS
144 # if( __clang_major__ > 3 || ( __clang_major__ == 3 && __clang_minor__ >= 4 ) ) && __cplusplus >= 201402L
145 # define DISTI_HAS_DEPRECATED_ATTRIBUTE
146 # define DISTI_HAS_CPP14
149 # define DISTI_HAS_TYPE_TRAITS
157 #ifdef DISTI_HAS_CPP14
158 # define DISTI_HAS_CPP11
159 # define DISTI_HAS_DEPRECATED_ATTRIBUTE
162 #ifdef DISTI_HAS_CPP11
163 # define DISTI_IF_HAS_CPP11( x ) x
164 # define DISTI_IF_HAS_CPP11_ELSE( x, y ) x
166 # define DISTI_HAS_RVAL_REFS
167 # define DISTI_HAS_METHOD_OVERRIDE
168 # define DISTI_HAS_SPECIAL_MEM_FUN_DEL
169 # define DISTI_HAS_TYPE_TRAITS
170 # define DISTI_HAS_STATIC_ASSERT
174 # define DISTI_IF_HAS_CPP11( x )
175 # define DISTI_IF_HAS_CPP11_ELSE( x, y ) y
181 #if !defined( DISTI_NO_RVAL_REFS ) && defined( DISTI_HAS_RVAL_REFS )
183 # define DISTI_RVAL_MOVE( x ) std::move( x )
184 # define DISTI_UREF_FORWARD( T, x ) std::forward<T>( x )
185 # define DISTI_UREF( T ) T&&
186 # define DISTI_IF_HAS_RVAL_REFS( x ) x
187 # define DISTI_IF_HAS_RVAL_REFS_ELSE( x, y ) x
189 # undef DISTI_HAS_RVAL_REFS
190 # define DISTI_RVAL_MOVE( x ) x
191 # define DISTI_UREF_FORWARD( T, x ) x
192 # define DISTI_UREF( T ) const T&
193 # define DISTI_IF_HAS_RVAL_REFS( x )
194 # define DISTI_IF_HAS_RVAL_REFS_ELSE( x, y ) y
198 #if !defined( DISTI_NO_METHOD_OVERRIDE ) && defined( DISTI_HAS_METHOD_OVERRIDE )
200 # define DISTI_METHOD_OVERRIDE override
202 # define DISTI_FINAL final
204 # undef DISTI_HAS_METHOD_OVERRIDE
205 # define DISTI_METHOD_OVERRIDE
210 #if !defined( DISTI_NO_NOEXCEPT ) && defined( DISTI_HAS_NOEXCEPT )
212 # define DISTI_FUNC_NOEXCEPT noexcept
214 # undef DISTI_HAS_NOEXCEPT
215 # define DISTI_FUNC_NOEXCEPT
219 #if !defined( DISTI_NO_SPECIAL_MEM_FUN_DEL ) && defined( DISTI_HAS_SPECIAL_MEM_FUN_DEL )
221 # define DISTI_SPECIAL_MEM_FUN_DELETE = delete
223 # undef DISTI_HAS_SPECIAL_MEM_FUN_DEL
224 # define DISTI_SPECIAL_MEM_FUN_DELETE
228 #if !defined( DISTI_NO_USER_DEFINED_LITERALS ) && defined( DISTI_HAS_USER_DEFINED_LITERALS )
229 # define DISTI_IF_HAS_USER_DEFINED_LITERAL( x ) x
231 # undef DISTI_HAS_USER_DEFINED_LITERALS
232 # define DISTI_IF_HAS_USER_DEFINED_LITERAL( x )
236 #if !defined( DISTI_NO_TYPE_TRAITS ) && defined( DISTI_HAS_TYPE_TRAITS )
239 # define DISTI_IF_HAS_TYPE_TRAITS_ELSE( x, y ) x
247 # define DISTI_STATIC_ASSERT_IS_CONVERTIBLE_TO( T, ConvertsTo ) DISTI_STATIC_ASSERT( ( std::is_convertible<T*, ConvertsTo*>::value ), class_does_not_inherit_from_##ConvertsTo );
250 # define DISTI_IS_TRIVIALLY_DESTRUCTIBLE( T ) ( std::is_trivially_destructible<T>() )
251 # define DISTI_TT_TRUE_TYPE std::true_type
252 # define DISTI_TT_FALSE_TYPE std::false_type
254 # undef DISTI_HAS_TYPE_TRAITS
255 # define DISTI_IF_HAS_TYPE_TRAITS_ELSE( x, y ) y
258 # 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 )
261 # define DISTI_IS_TRIVIALLY_DESTRUCTIBLE( T ) ( ::disti::_cppLangSupportDetail::is_trivially_destructible<T>() )
262 # define DISTI_TT_TRUE_TYPE ::disti::_cppLangSupportDetail::true_type
263 # define DISTI_TT_FALSE_TYPE ::disti::_cppLangSupportDetail::false_type
269 namespace _cppLangSupportDetail
285 template<
class T,
class U>
286 struct is_convertible
294 static Big Test( ... );
295 static Small Test( U );
301 value =
sizeof( Small ) ==
sizeof( ( Test( MakeT() ) ) )
306 template<
class T>
struct is_convertible<T, T > {
enum { value =
true }; };
307 template<
class T>
struct is_convertible<void, T > {
enum { value =
false }; };
308 template<
class T>
struct is_convertible<T, void> {
enum { value =
false }; };
309 template<>
struct is_convertible<void, void> {
enum { value =
true }; };
311 # if defined( DISTI_USER_DEFINED_IS_TRIVIALLY_DESTRUCTIBLE ) // Prefer the user-defined version if available
312 # define DISTI_TT_IS_TRIVIALLY_DESTRUCTIBLE( T ) ( DISTI_USER_DEFINED_IS_TRIVIALLY_DESTRUCTIBLE( T ) )
316 # if defined( _MSC_VER )
317 # define DISTI_TT_IS_TRIVIALLY_DESTRUCTIBLE( T ) ( __has_trivial_destructor( T ) || ( __is_pod( T ) && __has_trivial_constructor( T ) ) )
321 # define DISTI_TT_IS_TRIVIALLY_DESTRUCTIBLE( T ) ( __has_trivial_destructor( T ) )
324 # if defined( DISTI_USER_DEFINED_IS_DESTRUCTIBLE ) // Prefer the user-defined version if available
325 # define DISTI_TT_IS_DESTRUCTIBLE( T ) ( DISTI_USER_DEFINED_IS_DESTRUCTIBLE( T ) )
329 # define DISTI_TT_IS_DESTRUCTIBLE( T ) ( __is_pod( T ) || __is_class( T ) )
333 template<
typename T, T Val>
334 struct integral_constant
336 static const T value;
337 typedef T value_type;
338 typedef integral_constant<T, Val> type;
339 operator value_type() {
return value; }
342 template<
typename T, T Val>
343 const T integral_constant<T, Val>::value = Val;
345 typedef integral_constant<bool, true> true_type;
346 typedef integral_constant<bool, false> false_type;
349 struct is_trivially_destructible
350 : integral_constant<bool, DISTI_TT_IS_DESTRUCTIBLE( T ) && DISTI_TT_IS_TRIVIALLY_DESTRUCTIBLE( T )>
358 #if defined( DISTI_NO_STATIC_ASSERT )
359 # undef DISTI_HAS_STATIC_ASSERT
360 # define DISTI_STATIC_ASSERT( expr, msg )
362 # define DISTI_PREPROC_STRINGIFY_HELPER( s ) # s
363 # define DISTI_PREPROC_STRINGIFY( s ) DISTI_PREPROC_STRINGIFY_HELPER( s )
365 # if defined( DISTI_HAS_STATIC_ASSERT )
375 # define DISTI_STATIC_ASSERT( expr, msg ) static_assert( expr, DISTI_PREPROC_STRINGIFY( msg ) )
384 # define DISTI_STATIC_ASSERT_STR( expr, msg ) static_assert( expr, msg )
389 namespace _cppLangSupportDetail
394 struct CompileTimeError;
396 struct CompileTimeError<true>
398 CompileTimeError() {}
399 CompileTimeError(
const char* ) {}
414 # define DISTI_STATIC_ASSERT( expr, msg ) \
416 ::disti::_cppLangSupportDetail::CompileTimeError<( ( expr ) != 0 )> ERROR_##msg; \
426 # define DISTI_STATIC_ASSERT_STR( expr, msg ) \
428 ::disti::_cppLangSupportDetail::CompileTimeError<( ( expr ) != 0 )> ERROR_##__LINE__( msg ); \
429 (void)ERROR_##__LINE__; \
435 #if defined( DISTI_HAS_DEPRECATED_ATTRIBUTE ) && !defined( DISTI_NO_DEPRECATED_ATTRIBUTE )
436 # define DISTI_DEPRECATED( msg ) [[deprecated( msg )]]
438 # define DISTI_DEPRECATED( msg )
449 template<
class T>
struct MaxDigits10 {
static const unsigned long value = 0; };
450 template<>
struct MaxDigits10<float> {
static const unsigned long value = 2 + (FLT_MANT_DIG * 30103UL) / 100000UL; };
451 template<>
struct MaxDigits10<double> {
static const unsigned long value = 2 + (DBL_MANT_DIG * 30103UL) / 100000UL; };
452 template<>
struct MaxDigits10<long double> {
static const unsigned long value = 2 + (LDBL_MANT_DIG * 30103UL) / 100000UL; };
Definition: gls_cpp_lang_support.h:449
Definition: bmpimage.h:46