35 |
#include <vector> |
#include <vector> |
36 |
#include <map> |
#include <map> |
37 |
#include <time.h> |
#include <time.h> |
38 |
#if __cplusplus < 201103L |
|
39 |
|
#ifndef __has_extension |
40 |
|
# define __has_extension(x) 0 |
41 |
|
#endif |
42 |
|
|
43 |
|
#ifndef HAS_BUILTIN_TYPE_TRAITS |
44 |
|
# if __cplusplus >= 201103L |
45 |
|
# define HAS_BUILTIN_TYPE_TRAITS 1 |
46 |
|
# elif ( __has_extension(is_class) && __has_extension(is_enum) ) |
47 |
|
# define HAS_BUILTIN_TYPE_TRAITS 1 |
48 |
|
# elif ( __GNUC__ > 4 || ( __GNUC__ == 4 && __GNUC_MINOR__ >= 3 ) ) |
49 |
|
# define HAS_BUILTIN_TYPE_TRAITS 1 |
50 |
|
# elif _MSC_VER >= 1400 /* MS Visual C++ 8.0 (Visual Studio 2005) */ |
51 |
|
# define HAS_BUILTIN_TYPE_TRAITS 1 |
52 |
|
# elif __INTEL_COMPILER >= 1100 |
53 |
|
# define HAS_BUILTIN_TYPE_TRAITS 1 |
54 |
|
# else |
55 |
|
# define HAS_BUILTIN_TYPE_TRAITS 0 |
56 |
|
# endif |
57 |
|
#endif |
58 |
|
|
59 |
|
#if !HAS_BUILTIN_TYPE_TRAITS |
60 |
# include <tr1/type_traits> |
# include <tr1/type_traits> |
61 |
# define LIBGIG_IS_CLASS(type) std::tr1::__is_union_or_class<type>::value //NOTE: without compiler support we cannot distinguish union from class |
# define LIBGIG_IS_CLASS(type) std::tr1::__is_union_or_class<type>::value //NOTE: without compiler support we cannot distinguish union from class |
62 |
#else |
#else |
137 |
|
|
138 |
template<typename T> |
template<typename T> |
139 |
bool IsEnum(const T& data) { |
bool IsEnum(const T& data) { |
140 |
#if __cplusplus < 201103L |
#if !HAS_BUILTIN_TYPE_TRAITS |
141 |
return std::tr1::is_enum<T>::value; |
return std::tr1::is_enum<T>::value; |
142 |
#else |
#else |
143 |
return __is_enum(T); |
return __is_enum(T); |
146 |
|
|
147 |
template<typename T> |
template<typename T> |
148 |
bool IsUnion(const T& data) { |
bool IsUnion(const T& data) { |
149 |
#if __cplusplus < 201103L |
#if !HAS_BUILTIN_TYPE_TRAITS |
150 |
return false; // without compiler support we cannot distinguish union from class |
return false; // without compiler support we cannot distinguish union from class |
151 |
#else |
#else |
152 |
return __is_union(T); |
return __is_union(T); |
155 |
|
|
156 |
template<typename T> |
template<typename T> |
157 |
bool IsClass(const T& data) { |
bool IsClass(const T& data) { |
158 |
#if __cplusplus < 201103L |
#if !HAS_BUILTIN_TYPE_TRAITS |
159 |
return std::tr1::__is_union_or_class<T>::value; // without compiler support we cannot distinguish union from class |
return std::tr1::__is_union_or_class<T>::value; // without compiler support we cannot distinguish union from class |
160 |
#else |
#else |
161 |
return __is_class(T); |
return __is_class(T); |