X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fcore%2Fmeta.h;h=6998c5d1b8a712d69176a556e7c677bb745b9ec2;hb=bff9d86e0e0ccf23ce4c34024fa2fc33e1f8ff68;hp=f6dff160ff9be99df60b2522d28bdd368d2a7d95;hpb=b56eb5ec1da675da0c66abc53c1e4f6c4e4cccbd;p=libs%2Fcore.git diff --git a/source/core/meta.h b/source/core/meta.h index f6dff16..6998c5d 100644 --- a/source/core/meta.h +++ b/source/core/meta.h @@ -1,13 +1,8 @@ -/* $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 + namespace Msp { template @@ -18,6 +13,7 @@ template struct RemoveConst { typedef T Type; }; + template struct RemoveReference { typedef T Type; }; @@ -26,6 +22,54 @@ template struct RemoveReference { typedef T Type; }; + +template +struct RemoveConstReference +{ typedef typename RemoveConst::Type>::Type Type; }; + + +template +struct EnableIf; + +template +struct EnableIf +{ typedef R Yes; }; + +template +struct EnableIf +{ typedef R No; }; + + +/** +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