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