00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00020 #ifndef SHUTILITY_HPP
00021 #define SHUTILITY_HPP
00022
00027 #include <iosfwd>
00028 #include <map>
00029 #include "ShDllExport.hpp"
00030
00031 namespace SH {
00032
00034 SH_DLLEXPORT
00035 std::ostream& shPrintIndent(std::ostream& out, int indent);
00036
00040 template<bool B> struct ShCompileTimeChecker
00041 {
00042 ShCompileTimeChecker(...);
00043 };
00044 template<> struct ShCompileTimeChecker<false> {
00045 };
00046
00047 #define SH_STATIC_CHECK(expr, msg) \
00048 { \
00049 class SH_ERROR_##msg {} y; \
00050 (void)sizeof(ShCompileTimeChecker<(expr)>(y));\
00051 }
00052
00053 struct
00054 SH_DLLEXPORT ShIgnore {
00055 template<typename T>
00056 T& operator&(T& other) { return other; }
00057 };
00058
00060 template<bool B, typename T1, typename T2>
00061 struct SelectType;
00062
00063 template<typename T1, typename T2>
00064 struct SelectType<true, T1, T2> {
00065 typedef T1 type;
00066 };
00067
00068 template<typename T1, typename T2>
00069 struct SelectType<false, T1, T2> {
00070 typedef T2 type;
00071 };
00072
00074 template<typename T1, typename T2>
00075 struct MatchType {
00076 static const bool matches = false;
00077 };
00078
00079 template<typename T>
00080 struct MatchType<T, T> {
00081 static const bool matches = true;
00082 };
00083
00084 template<typename T, typename T1, typename T2>
00085 struct MatchEitherType {
00086 static const bool matches = MatchType<T1, T>::matches ||
00087 MatchType<T2, T>::matches;
00088 };
00089
00101 template<typename T, template<typename A> class B>
00102 struct MatchTemplateType {
00103 static const bool matches = false;
00104 };
00105
00106 template<typename T, template<typename A> class B>
00107 struct MatchTemplateType<B<T>, B> {
00108 static const bool matches = true;
00109 };
00110
00112 template<typename T, template<typename A> class B>
00113 struct TemplateParameterType;
00114
00115 template<typename T, template<typename A> class B>
00116 struct TemplateParameterType<B<T>, B> {
00117 typedef T type;
00118 };
00119
00120 }
00121
00122 #endif