/[svn]/libgig/trunk/src/Serialization.h
ViewVC logotype

Diff of /libgig/trunk/src/Serialization.h

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 3173 by schoenebeck, Wed May 10 23:07:28 2017 UTC revision 3178 by schoenebeck, Thu May 11 23:06:40 2017 UTC
# Line 35  Line 35 
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
# Line 116  namespace Serialization { Line 137  namespace Serialization {
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);
# Line 125  namespace Serialization { Line 146  namespace Serialization {
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);
# Line 134  namespace Serialization { Line 155  namespace Serialization {
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);

Legend:
Removed from v.3173  
changed lines
  Added in v.3178

  ViewVC Help
Powered by ViewVC