]> git.tdb.fi Git - libs/core.git/blobdiff - source/core/meta.h
Add move semantics to Variant
[libs/core.git] / source / core / meta.h
index 923096517dba8132a873de68a79344ab6e2910b1..35373013e5eb91d6faceae24592dcd298f4b1280 100644 (file)
@@ -1,36 +1,47 @@
 #ifndef MSP_CORE_META_H_
 #define MSP_CORE_META_H_
 
+#include <cstddef>
+#include "attributes.h"
+
 namespace Msp {
 
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
 template<typename T>
-struct RemoveConst
+struct DEPRECATED RemoveConst
 { typedef T Type; };
 
 template<typename T>
-struct RemoveConst<const T>
+struct DEPRECATED RemoveConst<const T>
 { typedef T Type; };
 
 
 template<typename T>
-struct RemoveReference
+struct DEPRECATED RemoveReference
 { typedef T Type; };
 
 template<typename T>
-struct RemoveReference<T &>
+struct DEPRECATED RemoveReference<T &>
 { typedef T Type; };
 
 
+template<typename T>
+struct DEPRECATED RemoveConstReference
+{ typedef typename RemoveConst<typename RemoveReference<T>::Type>::Type Type; };
+
+
 template<bool c, typename R>
-struct EnableIf;
+struct DEPRECATED EnableIf;
 
 template<typename R>
-struct EnableIf<true, R>
+struct DEPRECATED EnableIf<true, R>
 { typedef R Yes; };
 
 template<typename R>
-struct EnableIf<false, R>
+struct DEPRECATED EnableIf<false, R>
 { typedef R No; };
+#pragma GCC diagnostic pop
 
 
 /**
@@ -41,13 +52,28 @@ struct Sfinae
        struct Yes { char c[2]; };
        struct No { char c; };
 
-       template<size_t s>
+       template<typename T>
+       static No f(...);
+
+       template<typename C, typename T>
        struct Evaluate
        {
-               enum { value = (s==sizeof(Yes)) };
+               enum { value = (sizeof(C::template f<T>(0))==sizeof(Yes)) };
        };
 };
 
+
+struct CheckEqualityComparable: Sfinae
+{
+       static int &v;
+       template<typename T>
+       static Yes f(int (*)[sizeof(reinterpret_cast<const T &>(v)==reinterpret_cast<const T &>(v))]);
+       using Sfinae::f;
+};
+
+template<typename T>
+struct IsEqualityComparable: Sfinae::Evaluate<CheckEqualityComparable, T> { };
+
 } // namespace Msp
 
 #endif