]> git.tdb.fi Git - libs/datafile.git/blobdiff - source/type.h
Cosmetic changes
[libs/datafile.git] / source / type.h
index 58766289bc172a0e214917c961452976fac5645e..0e371e632a9bb4b66aee10520e5aab300726675e 100644 (file)
@@ -1,7 +1,8 @@
 #ifndef MSP_DATAFILE_TYPE_H_
 #define MSP_DATAFILE_TYPE_H_
 
-#include <msp/core/inttypes.h>
+#include <cstdint>
+#include <msp/core/meta.h>
 #include <msp/strings/lexicalcast.h>
 
 namespace Msp {
@@ -11,8 +12,10 @@ struct Symbol
 {
        std::string name;
 
+       Symbol() = default;
+
        template<typename T>
-       Symbol(const T &n): name(lexical_cast(n)) { }
+       Symbol(const T &n): name(lexical_cast<std::string>(n)) { }
 
        template<typename T> operator T() const { return lexical_cast<T>(name); }
 };
@@ -20,7 +23,7 @@ struct Symbol
 struct IntType
 {
        static const char signature = 'i';
-       typedef Int64 Store;
+       typedef std::int64_t Store;
        typedef Store Load;
 };
 
@@ -62,20 +65,16 @@ const char valid_signatures[] =
        0
 };
 
-template<typename T>
-struct HasLoadType
+struct CheckLoadType: Sfinae
 {
-       struct Yes { char c[2]; };
-       struct No { char c; };
-
-       template<typename U>
-       static Yes f(typename U::LoadType *);
-       template<typename U>
-       static No f(...);
-
-       enum { value = (sizeof(f<T>(0))==sizeof(Yes)) };
+       template<typename T>
+       static Yes f(typename T::LoadType *);
+       using Sfinae::f;
 };
 
+template<typename T>
+struct HasLoadType: Sfinae::Evaluate<CheckLoadType, T> { };
+
 template<typename T, bool lt = HasLoadType<T>::value>
 struct TypeInfo;
 
@@ -97,19 +96,11 @@ struct TypeInfo<long int, false>: IntType { };
 template<>
 struct TypeInfo<unsigned long int, false>: IntType { };
 
-#if defined(_MSC_VER)
-template<>
-struct TypeInfo<__int64, false>: IntType { };
-
-template<>
-struct TypeInfo<unsigned __int64, false>: IntType { };
-#elif defined(__GNUC__)
 template<>
 struct TypeInfo<long long int, false>: IntType { };
 
 template<>
 struct TypeInfo<unsigned long long int, false>: IntType { };
-#endif
 
 template<>
 struct TypeInfo<float, false>: FloatType { };
@@ -123,6 +114,12 @@ struct TypeInfo<bool, false>: BoolType { };
 template<>
 struct TypeInfo<std::string, false>: StringType { };
 
+template<>
+struct TypeInfo<char *, false>: StringType { };
+
+template<>
+struct TypeInfo<const char *, false>: StringType { };
+
 template<typename T>
 struct TypeInfo<const T, false>: TypeInfo<T> { };