]> git.tdb.fi Git - libs/datafile.git/blobdiff - source/type.h
Update a SFINAE construct
[libs/datafile.git] / source / type.h
index f40657eb14a07003a295cb979ae4813523183d17..fdd040d81adccd82b53b9e9509b48b4348b70ed8 100644 (file)
@@ -2,6 +2,7 @@
 #define MSP_DATAFILE_TYPE_H_
 
 #include <msp/core/inttypes.h>
+#include <msp/core/meta.h>
 #include <msp/strings/lexicalcast.h>
 
 namespace Msp {
@@ -64,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;