X-Git-Url: http://git.tdb.fi/?p=libs%2Fdatafile.git;a=blobdiff_plain;f=source%2Ftype.h;h=fdd040d81adccd82b53b9e9509b48b4348b70ed8;hp=58766289bc172a0e214917c961452976fac5645e;hb=HEAD;hpb=9867e5fdf99d7d6c9d83846c11a1cee6a9919be1 diff --git a/source/type.h b/source/type.h index 5876628..0e371e6 100644 --- a/source/type.h +++ b/source/type.h @@ -1,7 +1,8 @@ #ifndef MSP_DATAFILE_TYPE_H_ #define MSP_DATAFILE_TYPE_H_ -#include +#include +#include #include namespace Msp { @@ -11,8 +12,10 @@ struct Symbol { std::string name; + Symbol() = default; + template - Symbol(const T &n): name(lexical_cast(n)) { } + Symbol(const T &n): name(lexical_cast(n)) { } template operator T() const { return lexical_cast(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 -struct HasLoadType +struct CheckLoadType: Sfinae { - struct Yes { char c[2]; }; - struct No { char c; }; - - template - static Yes f(typename U::LoadType *); - template - static No f(...); - - enum { value = (sizeof(f(0))==sizeof(Yes)) }; + template + static Yes f(typename T::LoadType *); + using Sfinae::f; }; +template +struct HasLoadType: Sfinae::Evaluate { }; + template::value> struct TypeInfo; @@ -97,19 +96,11 @@ struct TypeInfo: IntType { }; template<> struct TypeInfo: IntType { }; -#if defined(_MSC_VER) -template<> -struct TypeInfo<__int64, false>: IntType { }; - -template<> -struct TypeInfo: IntType { }; -#elif defined(__GNUC__) template<> struct TypeInfo: IntType { }; template<> struct TypeInfo: IntType { }; -#endif template<> struct TypeInfo: FloatType { }; @@ -123,6 +114,12 @@ struct TypeInfo: BoolType { }; template<> struct TypeInfo: StringType { }; +template<> +struct TypeInfo: StringType { }; + +template<> +struct TypeInfo: StringType { }; + template struct TypeInfo: TypeInfo { };