X-Git-Url: http://git.tdb.fi/?p=libs%2Fcore.git;a=blobdiff_plain;f=source%2Fcore%2Fmeta.h;h=35373013e5eb91d6faceae24592dcd298f4b1280;hp=f6dff160ff9be99df60b2522d28bdd368d2a7d95;hb=HEAD;hpb=e38f9affa8a5d32168276b49535b560b1d7a907c diff --git a/source/core/meta.h b/source/core/meta.h index f6dff16..3537301 100644 --- a/source/core/meta.h +++ b/source/core/meta.h @@ -1,31 +1,79 @@ -/* $Id$ - -This file is part of libmspcore -Copyright © 2008 Mikko Rasa, Mikkosoft Productions -Distributed under the LGPL -*/ - #ifndef MSP_CORE_META_H_ #define MSP_CORE_META_H_ +#include +#include "attributes.h" + namespace Msp { +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wdeprecated-declarations" template -struct RemoveConst +struct DEPRECATED RemoveConst { typedef T Type; }; template -struct RemoveConst +struct DEPRECATED RemoveConst { typedef T Type; }; + template -struct RemoveReference +struct DEPRECATED RemoveReference { typedef T Type; }; template -struct RemoveReference +struct DEPRECATED RemoveReference { typedef T Type; }; + +template +struct DEPRECATED RemoveConstReference +{ typedef typename RemoveConst::Type>::Type Type; }; + + +template +struct DEPRECATED EnableIf; + +template +struct DEPRECATED EnableIf +{ typedef R Yes; }; + +template +struct DEPRECATED EnableIf +{ typedef R No; }; +#pragma GCC diagnostic pop + + +/** +Common fragments used in SFINAE-based decider constructs. +*/ +struct Sfinae +{ + struct Yes { char c[2]; }; + struct No { char c; }; + + template + static No f(...); + + template + struct Evaluate + { + enum { value = (sizeof(C::template f(0))==sizeof(Yes)) }; + }; +}; + + +struct CheckEqualityComparable: Sfinae +{ + static int &v; + template + static Yes f(int (*)[sizeof(reinterpret_cast(v)==reinterpret_cast(v))]); + using Sfinae::f; +}; + +template +struct IsEqualityComparable: Sfinae::Evaluate { }; + } // namespace Msp #endif